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-2013 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 #include "OgreHeaderPrefix.h" 00038 00039 namespace Ogre { 00048 class _OgreExport CompositorChain : public RenderTargetListener, public Viewport::Listener, public CompositorInstAlloc 00049 { 00050 public: 00051 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 00074 CompositorInstance* addCompositor(CompositorPtr filter, size_t addPosition=LAST, const String& scheme = StringUtil::BLANK); 00075 00080 void removeCompositor(size_t position=LAST); 00081 00084 size_t getNumCompositors(); 00085 00088 void removeAllCompositors(); 00089 00092 CompositorInstance *getCompositor(size_t index); 00093 00096 CompositorInstance *getCompositor(const String& name); 00097 00100 CompositorInstance* _getOriginalSceneCompositor(void) { return mOriginalScene; } 00101 00104 InstanceIterator getCompositors(); 00105 00112 void setCompositorEnabled(size_t position, bool state); 00113 00115 virtual void preRenderTargetUpdate(const RenderTargetEvent& evt); 00117 virtual void postRenderTargetUpdate(const RenderTargetEvent& evt); 00119 virtual void preViewportUpdate(const RenderTargetViewportEvent& evt); 00121 virtual void postViewportUpdate(const RenderTargetViewportEvent& evt); 00122 00124 virtual void viewportCameraChanged(Viewport* viewport); 00126 virtual void viewportDimensionsChanged(Viewport* viewport); 00128 virtual void viewportDestroyed(Viewport* viewport); 00129 00132 void _markDirty(); 00133 00136 Viewport *getViewport(); 00137 00141 void _removeInstance(CompositorInstance *i); 00142 00144 void _queuedOperation(CompositorInstance::RenderSystemOperation* op); 00145 00148 void _compile(); 00149 00152 CompositorInstance* getPreviousInstance(CompositorInstance* curr, bool activeOnly = true); 00155 CompositorInstance* getNextInstance(CompositorInstance* curr, bool activeOnly = true); 00156 00157 protected: 00159 Viewport *mViewport; 00160 00163 CompositorInstance *mOriginalScene; 00164 00166 Instances mInstances; 00167 00169 bool mDirty; 00171 bool mAnyCompositorsEnabled; 00172 00173 String mOriginalSceneScheme; 00174 00176 CompositorInstance::CompiledState mCompiledState; 00177 CompositorInstance::TargetOperation mOutputOperation; 00181 typedef vector<CompositorInstance::RenderSystemOperation*>::type RenderSystemOperations; 00182 RenderSystemOperations mRenderSystemOperations; 00183 00185 void clearCompiledState(); 00186 00189 void preTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam); 00190 00193 void postTargetOperation(CompositorInstance::TargetOperation &op, Viewport *vp, Camera *cam); 00194 00195 void createOriginalScene(); 00196 void destroyOriginalScene(); 00197 00199 void destroyResources(void); 00200 00202 class _OgreExport RQListener: public RenderQueueListener 00203 { 00204 public: 00205 RQListener() : mOperation(0), mSceneManager(0), mRenderSystem(0), mViewport(0) {} 00206 00209 virtual void renderQueueStarted(uint8 queueGroupId, const String& invocation, bool& skipThisInvocation); 00212 virtual void renderQueueEnded(uint8 queueGroupId, const String& invocation, bool& repeatThisInvocation); 00213 00215 void setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs); 00216 00218 void notifyViewport(Viewport* vp) { mViewport = vp; } 00219 00221 void flushUpTo(uint8 id); 00222 private: 00223 CompositorInstance::TargetOperation *mOperation; 00224 SceneManager *mSceneManager; 00225 RenderSystem *mRenderSystem; 00226 Viewport* mViewport; 00227 CompositorInstance::RenderSystemOpPairs::iterator currentOp, lastOp; 00228 }; 00229 RQListener mOurListener; 00231 unsigned int mOldClearEveryFrameBuffers; 00233 uint32 mOldVisibilityMask; 00235 bool mOldFindVisibleObjects; 00237 float mOldLodBias; 00239 String mOldMaterialScheme; 00241 bool mOldShadowsEnabled; 00242 00243 }; 00246 } // namespace Ogre 00247 00248 #include "OgreHeaderSuffix.h" 00249 00250 #endif // __CompositorChain_H__
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:41