Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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 
00152         virtual void _prepareForCompilation();
00153         
00157         virtual void _compileTargetOperations(CompiledState &compiledState);
00158         
00162         virtual void _compileOutputOperation(TargetOperation &finalState);
00163         
00166         Compositor *getCompositor();
00167         
00170         CompositionTechnique *getTechnique();
00171 
00174         CompositorChain *getChain();
00175 
00181         void addListener(Listener *l);
00182 
00186         void removeListener(Listener *l);
00187 
00190         void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
00191 
00194         void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
00195     private:
00197         Compositor *mCompositor;
00199         CompositionTechnique *mTechnique;
00201         CompositorChain *mChain;
00203         bool mEnabled;
00205         typedef std::map<String,TexturePtr> LocalTextureMap;
00206         LocalTextureMap mLocalTextures;
00207 
00211         typedef std::vector<RenderSystemOperation*> RenderSystemOperations;
00212         RenderSystemOperations mRenderSystemOperations;
00213 
00215         typedef std::vector<Listener*> Listeners;
00216         Listeners mListeners;
00217         
00219         CompositorInstance *mPreviousInstance;
00220         
00224         virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target);
00225         
00230         MaterialPtr createLocalMaterial();
00231         
00234         void createResources();
00235         
00238         void freeResources();
00239 
00242         void clearCompilationState();
00243         
00246         RenderTarget *getTargetForTex(const String &name);
00247         
00250         const String &getSourceForTex(const String &name);
00251 
00255         void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op);
00256         
00257         friend class CompositorChain;
00258     };
00259 }
00260 
00261 #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 Mar 12 14:37:39 2006