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

OgreCompositorChain.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 __CompositorChain_H__
00026 #define __CompositorChain_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreRenderTargetListener.h"
00030 #include "OgreRenderQueueListener.h"
00031 #include "OgreCompositorInstance.h"
00032 #include "OgreCompositor.h"
00033 namespace Ogre {
00034     
00037     class _OgreExport CompositorChain: public RenderTargetListener
00038     {
00039     public:
00040         CompositorChain(Viewport *vp);
00045         virtual ~CompositorChain();
00046         
00048         typedef std::vector<CompositorInstance*> Instances;
00049         typedef VectorIterator<Instances> InstanceIterator;
00050         
00052         static const size_t LAST = (size_t)-1;
00054         static const size_t BEST = 0;
00055         
00062         CompositorInstance* addCompositor(CompositorPtr filter, size_t addPosition=LAST, size_t technique=BEST);
00063     
00067         void removeCompositor(size_t position=LAST);
00068         
00071         size_t getNumCompositors();
00072         
00075         void removeAllCompositors();
00076         
00079         CompositorInstance *getCompositor(size_t index);
00080 
00083         CompositorInstance* _getOriginalSceneCompositor(void) { return mOriginalScene; }
00084     
00087         InstanceIterator getCompositors();
00088     
00094         void setCompositorEnabled(size_t position, bool state);
00095     
00097         virtual void preRenderTargetUpdate(const RenderTargetEvent& evt);
00099         virtual void preViewportUpdate(const RenderTargetViewportEvent& evt);
00101         virtual void postViewportUpdate(const RenderTargetViewportEvent& evt);
00103         virtual void viewportRemoved(const RenderTargetViewportEvent& evt);
00104         
00107         void _markDirty();
00108         
00111         Viewport *getViewport();
00112 
00116         void _removeInstance(CompositorInstance *i);
00117 
00119         void _queuedOperation(CompositorInstance::RenderSystemOperation* op);
00120 
00121     protected:    
00123         Viewport *mViewport;
00124         
00127         CompositorInstance *mOriginalScene;
00128         
00130         Instances mInstances;
00131         
00133         bool mDirty;
00135         bool mAnyCompositorsEnabled;
00136 
00138         CompositorInstance::CompiledState mCompiledState;
00139         CompositorInstance::TargetOperation mOutputOperation;
00143         typedef std::vector<CompositorInstance::RenderSystemOperation*> RenderSystemOperations;
00144         RenderSystemOperations mRenderSystemOperations;
00145 
00146         
00148         void clearCompiledState();
00149 
00152         void _compile();
00153         
00156         void preTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam);
00157         
00160         void postTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam);
00161 
00163         void destroyResources(void);
00164 
00166         class RQListener: public RenderQueueListener
00167         {
00168         public:
00171             virtual void renderQueueStarted(uint8 id, const String& invocation, bool& skipThisQueue);
00174             virtual void renderQueueEnded(uint8 id, const String& invocation, bool& repeatThisQueue);
00175 
00177             void setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs);
00178 
00180             void notifyViewport(Viewport* vp) { mViewport = vp; }
00181 
00183             void flushUpTo(uint8 id);
00184         private:
00185             CompositorInstance::TargetOperation *mOperation;
00186             SceneManager *mSceneManager;
00187             RenderSystem *mRenderSystem;
00188             Viewport* mViewport;
00189             CompositorInstance::RenderSystemOpPairs::iterator currentOp, lastOp;
00190         };
00191         RQListener mOurListener;
00193         unsigned int mOldClearEveryFrameBuffers;
00195         uint32 mOldVisibilityMask;
00197         bool mOldFindVisibleObjects;
00199         float mOldLodBias;     
00201         String mOldMaterialScheme;
00202     };
00203 }
00204 
00205 #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 Sep 17 15:39:07 2006