00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2006 Torus Knot Software Ltd 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 00024 You may alternatively use this source under the terms of a specific version of 00025 the OGRE Unrestricted License provided you have obtained such a license from 00026 Torus Knot Software Ltd. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __CompositorInstance_H__ 00030 #define __CompositorInstance_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgreMaterial.h" 00034 #include "OgreTexture.h" 00035 #include "OgreRenderQueue.h" 00036 namespace Ogre { 00037 const size_t RENDER_QUEUE_COUNT = RENDER_QUEUE_OVERLAY+1; 00038 00042 class _OgreExport CompositorInstance 00043 { 00044 public: 00045 CompositorInstance(Compositor *filter, CompositionTechnique *technique, CompositorChain *chain); 00046 virtual ~CompositorInstance(); 00050 class _OgreExport Listener 00051 { 00052 public: 00053 virtual ~Listener(); 00054 00064 virtual void notifyMaterialSetup(uint32 pass_id, MaterialPtr &mat); 00065 00074 virtual void notifyMaterialRender(uint32 pass_id, MaterialPtr &mat); 00075 }; 00080 class RenderSystemOperation 00081 { 00082 public: 00083 virtual ~RenderSystemOperation(); 00085 virtual void execute(SceneManager *sm, RenderSystem *rs) = 0; 00086 }; 00087 typedef std::map<int, MaterialPtr> QuadMaterialMap; 00088 typedef std::pair<int, RenderSystemOperation*> RenderSystemOpPair; 00089 typedef std::vector<RenderSystemOpPair> RenderSystemOpPairs; 00092 class TargetOperation 00093 { 00094 public: 00095 TargetOperation() 00096 { 00097 } 00098 TargetOperation(RenderTarget *target): 00099 target(target), currentQueueGroupID(0), visibilityMask(0xFFFFFFFF), 00100 lodBias(1.0f), 00101 onlyInitial(false), hasBeenRendered(false), findVisibleObjects(false) 00102 { 00103 } 00105 RenderTarget *target; 00106 00108 int currentQueueGroupID; 00109 00112 RenderSystemOpPairs renderSystemOperations; 00113 00116 uint32 visibilityMask; 00117 00120 float lodBias; 00121 00124 typedef std::bitset<RENDER_QUEUE_COUNT> RenderQueueBitSet; 00125 00127 RenderQueueBitSet renderQueues; 00128 00131 bool onlyInitial; 00135 bool hasBeenRendered; 00138 bool findVisibleObjects; 00140 String materialScheme; 00141 }; 00142 typedef std::vector<TargetOperation> CompiledState; 00143 00147 void setEnabled(bool value); 00148 00151 bool getEnabled(); 00152 00162 const String& getTextureInstanceName(const String& name); 00163 00164 00168 virtual void _compileTargetOperations(CompiledState &compiledState); 00169 00173 virtual void _compileOutputOperation(TargetOperation &finalState); 00174 00177 Compositor *getCompositor(); 00178 00181 CompositionTechnique *getTechnique(); 00182 00185 CompositorChain *getChain(); 00186 00192 void addListener(Listener *l); 00193 00197 void removeListener(Listener *l); 00198 00201 void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat); 00202 00205 void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat); 00206 private: 00208 Compositor *mCompositor; 00210 CompositionTechnique *mTechnique; 00212 CompositorChain *mChain; 00214 bool mEnabled; 00216 typedef std::map<String,TexturePtr> LocalTextureMap; 00217 LocalTextureMap mLocalTextures; 00218 00220 typedef std::vector<Listener*> Listeners; 00221 Listeners mListeners; 00222 00224 CompositorInstance *mPreviousInstance; 00225 00229 virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target); 00230 00235 MaterialPtr createLocalMaterial(); 00236 00239 void createResources(); 00240 00243 void freeResources(); 00244 00247 RenderTarget *getTargetForTex(const String &name); 00248 00251 const String &getSourceForTex(const String &name); 00252 00256 void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op); 00257 00258 friend class CompositorChain; 00259 }; 00260 } 00261 00262 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 25 13:03:13 2007