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-2012 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 #include "OgreViewport.h" 00037 00038 namespace Ogre { 00047 class _OgreExport CompositorChain : public RenderTargetListener, public Viewport::Listener, public CompositorInstAlloc 00048 { 00049 public: 00050 CompositorChain(Viewport *vp); 00055 virtual ~CompositorChain(); 00056 00058 typedef vector<CompositorInstance*>::type Instances; 00059 typedef VectorIterator<Instances> InstanceIterator; 00060 00062 static const size_t LAST = (size_t)-1; 00064 static const size_t BEST = 0; 00065 00071 CompositorInstance* addCompositor(CompositorPtr filter, size_t addPosition=LAST, const String& scheme = StringUtil::BLANK); 00072 00076 void removeCompositor(size_t position=LAST); 00077 00080 size_t getNumCompositors(); 00081 00084 void removeAllCompositors(); 00085 00088 CompositorInstance *getCompositor(size_t index); 00089 00092 CompositorInstance *getCompositor(const String& name); 00093 00096 CompositorInstance* _getOriginalSceneCompositor(void) { return mOriginalScene; } 00097 00100 InstanceIterator getCompositors(); 00101 00107 void setCompositorEnabled(size_t position, bool state); 00108 00110 virtual void preRenderTargetUpdate(const RenderTargetEvent& evt); 00112 virtual void postRenderTargetUpdate(const RenderTargetEvent& evt); 00114 virtual void preViewportUpdate(const RenderTargetViewportEvent& evt); 00116 virtual void postViewportUpdate(const RenderTargetViewportEvent& evt); 00117 00119 virtual void viewportCameraChanged(Viewport* viewport); 00121 virtual void viewportDimensionsChanged(Viewport* viewport); 00123 virtual void viewportDestroyed(Viewport* viewport); 00124 00127 void _markDirty(); 00128 00131 Viewport *getViewport(); 00132 00136 void _removeInstance(CompositorInstance *i); 00137 00139 void _queuedOperation(CompositorInstance::RenderSystemOperation* op); 00140 00143 void _compile(); 00144 00147 CompositorInstance* getPreviousInstance(CompositorInstance* curr, bool activeOnly = true); 00150 CompositorInstance* getNextInstance(CompositorInstance* curr, bool activeOnly = true); 00151 00152 protected: 00154 Viewport *mViewport; 00155 00158 CompositorInstance *mOriginalScene; 00159 00161 Instances mInstances; 00162 00164 bool mDirty; 00166 bool mAnyCompositorsEnabled; 00167 00168 String mOriginalSceneScheme; 00169 00171 CompositorInstance::CompiledState mCompiledState; 00172 CompositorInstance::TargetOperation mOutputOperation; 00176 typedef vector<CompositorInstance::RenderSystemOperation*>::type RenderSystemOperations; 00177 RenderSystemOperations mRenderSystemOperations; 00178 00180 void clearCompiledState(); 00181 00184 void preTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam); 00185 00188 void postTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam); 00189 00190 void createOriginalScene(); 00191 void destroyOriginalScene(); 00192 00194 void destroyResources(void); 00195 00197 class _OgreExport RQListener: public RenderQueueListener 00198 { 00199 public: 00202 virtual void renderQueueStarted(uint8 id, const String& invocation, bool& skipThisQueue); 00205 virtual void renderQueueEnded(uint8 id, const String& invocation, bool& repeatThisQueue); 00206 00208 void setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs); 00209 00211 void notifyViewport(Viewport* vp) { mViewport = vp; } 00212 00214 void flushUpTo(uint8 id); 00215 private: 00216 CompositorInstance::TargetOperation *mOperation; 00217 SceneManager *mSceneManager; 00218 RenderSystem *mRenderSystem; 00219 Viewport* mViewport; 00220 CompositorInstance::RenderSystemOpPairs::iterator currentOp, lastOp; 00221 }; 00222 RQListener mOurListener; 00224 unsigned int mOldClearEveryFrameBuffers; 00226 uint32 mOldVisibilityMask; 00228 bool mOldFindVisibleObjects; 00230 float mOldLodBias; 00232 String mOldMaterialScheme; 00234 bool mOldShadowsEnabled; 00235 00236 }; 00239 } 00240 00241 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:23 2012