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-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 __CompositorChain_H__
00030 #define __CompositorChain_H__
00031 
00032 #include "OgrePrerequisites.h"
00033 #include "OgreRenderTargetListener.h"
00034 #include "OgreRenderQueueListener.h"
00035 #include "OgreCompositorInstance.h"
00036 #include "OgreCompositor.h"
00037 namespace Ogre {
00038     
00041     class _OgreExport CompositorChain: public RenderTargetListener
00042     {
00043     public:
00044         CompositorChain(Viewport *vp);
00049         virtual ~CompositorChain();
00050         
00052         typedef std::vector<CompositorInstance*> Instances;
00053         typedef VectorIterator<Instances> InstanceIterator;
00054         
00056         static const size_t LAST = (size_t)-1;
00058         static const size_t BEST = 0;
00059         
00066         CompositorInstance* addCompositor(CompositorPtr filter, size_t addPosition=LAST, size_t technique=BEST);
00067     
00071         void removeCompositor(size_t position=LAST);
00072         
00075         size_t getNumCompositors();
00076         
00079         void removeAllCompositors();
00080         
00083         CompositorInstance *getCompositor(size_t index);
00084 
00087         CompositorInstance* _getOriginalSceneCompositor(void) { return mOriginalScene; }
00088     
00091         InstanceIterator getCompositors();
00092     
00098         void setCompositorEnabled(size_t position, bool state);
00099     
00101         virtual void preRenderTargetUpdate(const RenderTargetEvent& evt);
00103         virtual void preViewportUpdate(const RenderTargetViewportEvent& evt);
00105         virtual void postViewportUpdate(const RenderTargetViewportEvent& evt);
00107         virtual void viewportRemoved(const RenderTargetViewportEvent& evt);
00108         
00111         void _markDirty();
00112         
00115         Viewport *getViewport();
00116 
00120         void _removeInstance(CompositorInstance *i);
00121 
00123         void _queuedOperation(CompositorInstance::RenderSystemOperation* op);
00124 
00127         void _compile();
00128     protected:    
00130         Viewport *mViewport;
00131         
00134         CompositorInstance *mOriginalScene;
00135         
00137         Instances mInstances;
00138         
00140         bool mDirty;
00142         bool mAnyCompositorsEnabled;
00143 
00145         CompositorInstance::CompiledState mCompiledState;
00146         CompositorInstance::TargetOperation mOutputOperation;
00150         typedef std::vector<CompositorInstance::RenderSystemOperation*> RenderSystemOperations;
00151         RenderSystemOperations mRenderSystemOperations;
00152 
00153         
00155         void clearCompiledState();
00156         
00159         void preTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam);
00160         
00163         void postTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam);
00164 
00166         void destroyResources(void);
00167 
00169         class RQListener: public RenderQueueListener
00170         {
00171         public:
00174             virtual void renderQueueStarted(uint8 id, const String& invocation, bool& skipThisQueue);
00177             virtual void renderQueueEnded(uint8 id, const String& invocation, bool& repeatThisQueue);
00178 
00180             void setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs);
00181 
00183             void notifyViewport(Viewport* vp) { mViewport = vp; }
00184 
00186             void flushUpTo(uint8 id);
00187         private:
00188             CompositorInstance::TargetOperation *mOperation;
00189             SceneManager *mSceneManager;
00190             RenderSystem *mRenderSystem;
00191             Viewport* mViewport;
00192             CompositorInstance::RenderSystemOpPairs::iterator currentOp, lastOp;
00193         };
00194         RQListener mOurListener;
00196         unsigned int mOldClearEveryFrameBuffers;
00198         uint32 mOldVisibilityMask;
00200         bool mOldFindVisibleObjects;
00202         float mOldLodBias;     
00204         String mOldMaterialScheme;
00205     };
00206 }
00207 
00208 #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 25 13:03:13 2007