# 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-2009 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028 #ifndef __CompositorChain_H__
    00029 #define __CompositorChain_H__
    00030
    00031 #include "OgrePrerequisites.h"
    00032 #include "OgreRenderTargetListener.h"
    00033 #include "OgreRenderQueueListener.h"
    00034 #include "OgreCompositorInstance.h"
    00035 #include "OgreCompositor.h"
    00036 namespace Ogre {
    00037
    00046     class _OgreExport CompositorChain: public RenderTargetListener, public CompositorInstAlloc
    00047     {
    00048     public:
    00049         CompositorChain(Viewport *vp);
    00054         virtual ~CompositorChain();
    00055
    00057         typedef vector<CompositorInstance*>::type Instances;
    00058         typedef VectorIterator<Instances> InstanceIterator;
    00059
    00061         static const size_t LAST = (size_t)-1;
    00063         static const size_t BEST = 0;
    00064
    00070         CompositorInstance* addCompositor(CompositorPtr filter, size_t addPosition=LAST, const String& scheme = StringUtil::BLANK);
    00071
    00075         void removeCompositor(size_t position=LAST);
    00076
    00079         size_t getNumCompositors();
    00080
    00083         void removeAllCompositors();
    00084
    00087         CompositorInstance *getCompositor(size_t index);
    00088
    00091         CompositorInstance *getCompositor(const String& name);
    00092
    00095         CompositorInstance* _getOriginalSceneCompositor(void) { return mOriginalScene; }
    00096
    00099         InstanceIterator getCompositors();
    00100
    00106         void setCompositorEnabled(size_t position, bool state);
    00107
    00109         virtual void preRenderTargetUpdate(const RenderTargetEvent& evt);
    00111         virtual void postRenderTargetUpdate(const RenderTargetEvent& evt);
    00113         virtual void preViewportUpdate(const RenderTargetViewportEvent& evt);
    00115         virtual void postViewportUpdate(const RenderTargetViewportEvent& evt);
    00117         virtual void viewportRemoved(const RenderTargetViewportEvent& evt);
    00118
    00121         void _markDirty();
    00122
    00125         Viewport *getViewport();
    00126
    00128         void _notifyViewport(Viewport* vp);
    00129
    00133         void _removeInstance(CompositorInstance *i);
    00134
    00136         void _queuedOperation(CompositorInstance::RenderSystemOperation* op);
    00137
    00140         void _compile();
    00141
    00144         CompositorInstance* getPreviousInstance(CompositorInstance* curr, bool activeOnly = true);
    00147         CompositorInstance* getNextInstance(CompositorInstance* curr, bool activeOnly = true);
    00148
    00149     protected:
    00151         Viewport *mViewport;
    00152
    00155         CompositorInstance *mOriginalScene;
    00156
    00158         Instances mInstances;
    00159
    00161         bool mDirty;
    00163         bool mAnyCompositorsEnabled;
    00164
    00166         CompositorInstance::CompiledState mCompiledState;
    00167         CompositorInstance::TargetOperation mOutputOperation;
    00171         typedef vector<CompositorInstance::RenderSystemOperation*>::type RenderSystemOperations;
    00172         RenderSystemOperations mRenderSystemOperations;
    00173
    00174
    00176         void clearCompiledState();
    00177
    00180         void preTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam);
    00181
    00184         void postTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam);
    00185
    00187         void destroyResources(void);
    00188
    00190         class _OgreExport RQListener: public RenderQueueListener
    00191         {
    00192         public:
    00195             virtual void renderQueueStarted(uint8 id, const String& invocation, bool& skipThisQueue);
    00198             virtual void renderQueueEnded(uint8 id, const String& invocation, bool& repeatThisQueue);
    00199
    00201             void setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs);
    00202
    00204             void notifyViewport(Viewport* vp) { mViewport = vp; }
    00205
    00207             void flushUpTo(uint8 id);
    00208         private:
    00209             CompositorInstance::TargetOperation *mOperation;
    00210             SceneManager *mSceneManager;
    00211             RenderSystem *mRenderSystem;
    00212             Viewport* mViewport;
    00213             CompositorInstance::RenderSystemOpPairs::iterator currentOp, lastOp;
    00214         };
    00215         RQListener mOurListener;
    00217         unsigned int mOldClearEveryFrameBuffers;
    00219         uint32 mOldVisibilityMask;
    00221         bool mOldFindVisibleObjects;
    00223         float mOldLodBias;
    00225         String mOldMaterialScheme;
    00227         bool mOldShadowsEnabled;
    00228
    00229     };
    00232 }
    00233
    00234 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:51