Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OgreCompositorInstance.h

Go to the documentation of this file.
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-2005 The OGRE Team
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 */
00025 #ifndef __CompositorInstance_H__
00026 #define __CompositorInstance_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreMaterial.h"
00030 #include "OgreTexture.h"
00031 #include "OgreRenderQueue.h"
00032 namespace Ogre {
00033     const size_t RENDER_QUEUE_COUNT = RENDER_QUEUE_OVERLAY+1;       
00034             
00038     class _OgreExport CompositorInstance
00039     {
00040     public:
00041         CompositorInstance(Compositor *filter, CompositionTechnique *technique, CompositorChain *chain);
00042         virtual ~CompositorInstance();
00046         class _OgreExport Listener
00047         {
00048         public:
00049             virtual ~Listener();
00050 
00060             virtual void notifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
00061 
00070             virtual void notifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
00071         };
00076         class RenderSystemOperation
00077         {
00078         public:
00079             virtual ~RenderSystemOperation();
00081             virtual void execute(SceneManager *sm, RenderSystem *rs) = 0;
00082         };
00083         typedef std::map<int, MaterialPtr> QuadMaterialMap;
00084         typedef std::pair<int, RenderSystemOperation*> RenderSystemOpPair;
00085         typedef std::vector<RenderSystemOpPair> RenderSystemOpPairs;
00088         class TargetOperation
00089         {
00090         public:
00091             TargetOperation()
00092             { 
00093             }
00094             TargetOperation(RenderTarget *target):
00095                 target(target), currentQueueGroupID(0), visibilityMask(0xFFFFFFFF),
00096                 lodBias(1.0f),
00097                 onlyInitial(false), hasBeenRendered(false), findVisibleObjects(false)
00098             { 
00099             }
00101             RenderTarget *target;
00102 
00104             int currentQueueGroupID;
00105 
00108             RenderSystemOpPairs renderSystemOperations;
00109 
00112             uint32 visibilityMask;
00113             
00116             float lodBias;
00117             
00120             typedef std::bitset<RENDER_QUEUE_COUNT> RenderQueueBitSet;
00121 
00123             RenderQueueBitSet renderQueues;
00124             
00127             bool onlyInitial;
00131             bool hasBeenRendered;
00134             bool findVisibleObjects;
00136             String materialScheme;
00137         };
00138         typedef std::vector<TargetOperation> CompiledState;
00139         
00143         void setEnabled(bool value);
00144         
00147         bool getEnabled();
00148 
00158         const String& getTextureInstanceName(const String& name);
00159 
00160        
00164         virtual void _compileTargetOperations(CompiledState &compiledState);
00165         
00169         virtual void _compileOutputOperation(TargetOperation &finalState);
00170         
00173         Compositor *getCompositor();
00174         
00177         CompositionTechnique *getTechnique();
00178 
00181         CompositorChain *getChain();
00182 
00188         void addListener(Listener *l);
00189 
00193         void removeListener(Listener *l);
00194 
00197         void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
00198 
00201         void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
00202     private:
00204         Compositor *mCompositor;
00206         CompositionTechnique *mTechnique;
00208         CompositorChain *mChain;
00210         bool mEnabled;
00212         typedef std::map<String,TexturePtr> LocalTextureMap;
00213         LocalTextureMap mLocalTextures;
00214 
00216         typedef std::vector<Listener*> Listeners;
00217         Listeners mListeners;
00218         
00220         CompositorInstance *mPreviousInstance;
00221         
00225         virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target);
00226         
00231         MaterialPtr createLocalMaterial();
00232         
00235         void createResources();
00236         
00239         void freeResources();
00240 
00243         RenderTarget *getTargetForTex(const String &name);
00244         
00247         const String &getSourceForTex(const String &name);
00248 
00252         void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op);
00253         
00254         friend class CompositorChain;
00255     };
00256 }
00257 
00258 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jan 21 10:01:35 2007