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-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_MAX+1;       
00038             
00042     class _OgreExport CompositorInstance : public CompositorInstAlloc
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 : public CompositorInstAlloc
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                 shadowsEnabled(true)
00103             { 
00104             }
00106             RenderTarget *target;
00107 
00109             int currentQueueGroupID;
00110 
00113             RenderSystemOpPairs renderSystemOperations;
00114 
00117             uint32 visibilityMask;
00118             
00121             float lodBias;
00122             
00125             typedef std::bitset<RENDER_QUEUE_COUNT> RenderQueueBitSet;
00126 
00128             RenderQueueBitSet renderQueues;
00129             
00132             bool onlyInitial;
00136             bool hasBeenRendered;
00139             bool findVisibleObjects;
00141             String materialScheme;
00143             bool shadowsEnabled;
00144         };
00145         typedef std::vector<TargetOperation> CompiledState;
00146         
00150         void setEnabled(bool value);
00151         
00154         bool getEnabled();
00155 
00166         const String& getTextureInstanceName(const String& name, size_t mrtIndex);
00167 
00174         RenderTarget* getRenderTarget(const String& name);
00175 
00176        
00180         virtual void _compileTargetOperations(CompiledState &compiledState);
00181         
00185         virtual void _compileOutputOperation(TargetOperation &finalState);
00186         
00189         Compositor *getCompositor();
00190         
00193         CompositionTechnique *getTechnique();
00194 
00197         CompositorChain *getChain();
00198 
00204         void addListener(Listener *l);
00205 
00209         void removeListener(Listener *l);
00210 
00213         void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
00214 
00217         void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
00218     private:
00220         Compositor *mCompositor;
00222         CompositionTechnique *mTechnique;
00224         CompositorChain *mChain;
00226         bool mEnabled;
00228         typedef std::map<String,TexturePtr> LocalTextureMap;
00229         LocalTextureMap mLocalTextures;
00231         typedef std::map<String,MultiRenderTarget*> LocalMRTMap;
00232         LocalMRTMap mLocalMRTs;
00233 
00235         typedef std::vector<Listener*> Listeners;
00236         Listeners mListeners;
00237         
00239         CompositorInstance *mPreviousInstance;
00240         
00244         virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target);
00245         
00250         MaterialPtr createLocalMaterial(const String& srcName);
00251         
00254         void createResources();
00255         
00258         void freeResources();
00259 
00262         RenderTarget *getTargetForTex(const String &name);
00263         
00268         const String &getSourceForTex(const String &name, size_t mrtIndex = 0);
00269 
00273         void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op);
00274 
00276         String getMRTTexLocalName(const String& baseName, size_t attachment);
00277 
00281         void deriveTextureRenderTargetOptions(const String& texname,
00282             bool *hwGammaWrite, uint *fsaa);
00283         
00284         friend class CompositorChain;
00285     };
00286 }
00287 
00288 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:22 2009