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 __CompositorInstance_H__ 00029 #define __CompositorInstance_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 #include "OgreMaterialManager.h" 00033 #include "OgreTexture.h" 00034 #include "OgreRenderQueue.h" 00035 #include "OgreCompositionTechnique.h" 00036 00037 namespace Ogre { 00044 const size_t RENDER_QUEUE_COUNT = RENDER_QUEUE_MAX+1; 00045 00049 class _OgreExport CompositorInstance : public CompositorInstAlloc 00050 { 00051 public: 00052 CompositorInstance(CompositionTechnique *technique, CompositorChain *chain); 00053 virtual ~CompositorInstance(); 00057 class _OgreExport Listener 00058 { 00059 public: 00060 virtual ~Listener(); 00061 00071 virtual void notifyMaterialSetup(uint32 pass_id, MaterialPtr &mat); 00072 00081 virtual void notifyMaterialRender(uint32 pass_id, MaterialPtr &mat); 00082 00086 virtual void notifyResourcesCreated(bool forResizeOnly); 00087 00088 }; 00093 class _OgreExport RenderSystemOperation : public CompositorInstAlloc 00094 { 00095 public: 00096 virtual ~RenderSystemOperation(); 00098 virtual void execute(SceneManager *sm, RenderSystem *rs) = 0; 00099 }; 00100 typedef map<int, MaterialPtr>::type QuadMaterialMap; 00101 typedef std::pair<int, RenderSystemOperation*> RenderSystemOpPair; 00102 typedef vector<RenderSystemOpPair>::type RenderSystemOpPairs; 00105 class TargetOperation 00106 { 00107 public: 00108 TargetOperation() 00109 { 00110 } 00111 TargetOperation(RenderTarget *inTarget): 00112 target(inTarget), currentQueueGroupID(0), visibilityMask(0xFFFFFFFF), 00113 lodBias(1.0f), 00114 onlyInitial(false), hasBeenRendered(false), findVisibleObjects(false), 00115 materialScheme(MaterialManager::DEFAULT_SCHEME_NAME), shadowsEnabled(true) 00116 { 00117 } 00119 RenderTarget *target; 00120 00122 int currentQueueGroupID; 00123 00126 RenderSystemOpPairs renderSystemOperations; 00127 00130 uint32 visibilityMask; 00131 00134 float lodBias; 00135 00138 typedef std::bitset<RENDER_QUEUE_COUNT> RenderQueueBitSet; 00139 00141 RenderQueueBitSet renderQueues; 00142 00145 bool onlyInitial; 00149 bool hasBeenRendered; 00152 bool findVisibleObjects; 00154 String materialScheme; 00156 bool shadowsEnabled; 00157 }; 00158 typedef vector<TargetOperation>::type CompiledState; 00159 00164 void setEnabled(bool value); 00165 00168 bool getEnabled() const { return mEnabled; } 00169 00175 void setAlive(bool value); 00176 00179 bool getAlive() const { return mAlive; } 00180 00191 const String& getTextureInstanceName(const String& name, size_t mrtIndex); 00192 00203 TexturePtr getTextureInstance(const String& name, size_t mrtIndex); 00204 00211 RenderTarget* getRenderTarget(const String& name); 00212 00213 00217 virtual void _compileTargetOperations(CompiledState &compiledState); 00218 00222 virtual void _compileOutputOperation(TargetOperation &finalState); 00223 00226 Compositor *getCompositor(); 00227 00230 CompositionTechnique *getTechnique(); 00231 00237 void setTechnique(CompositionTechnique* tech, bool reuseTextures = true); 00238 00250 void setScheme(const String& schemeName, bool reuseTextures = true); 00251 00253 const String& getScheme() const { return mTechnique ? mTechnique->getSchemeName() : StringUtil::BLANK; } 00254 00260 void notifyResized(); 00261 00264 CompositorChain *getChain(); 00265 00271 void addListener(Listener *l); 00272 00276 void removeListener(Listener *l); 00277 00280 void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat); 00281 00284 void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat); 00285 00288 void _fireNotifyResourcesCreated(bool forResizeOnly); 00289 private: 00291 Compositor *mCompositor; 00293 CompositionTechnique *mTechnique; 00295 CompositorChain *mChain; 00297 bool mEnabled; 00299 bool mAlive; 00301 typedef map<String,TexturePtr>::type LocalTextureMap; 00302 LocalTextureMap mLocalTextures; 00304 typedef map<String,MultiRenderTarget*>::type LocalMRTMap; 00305 LocalMRTMap mLocalMRTs; 00306 typedef map<CompositionTechnique::TextureDefinition*, TexturePtr>::type ReserveTextureMap; 00311 ReserveTextureMap mReserveTextures; 00312 00314 typedef vector<Listener*>::type Listeners; 00315 Listeners mListeners; 00316 00318 CompositorInstance *mPreviousInstance; 00319 00323 virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target); 00324 00329 MaterialPtr createLocalMaterial(const String& srcName); 00330 00333 void createResources(bool forResizeOnly); 00334 00337 void freeResources(bool forResizeOnly, bool clearReserveTextures); 00338 00341 RenderTarget *getTargetForTex(const String &name); 00342 00347 const String &getSourceForTex(const String &name, size_t mrtIndex = 0); 00348 00352 void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op); 00353 00355 String getMRTTexLocalName(const String& baseName, size_t attachment); 00356 00360 void deriveTextureRenderTargetOptions(const String& texname, 00361 bool *hwGammaWrite, uint *fsaa, String* fsaaHint); 00362 00364 void notifyCameraChanged(Camera* camera); 00365 00366 friend class CompositorChain; 00367 }; 00371 } 00372 00373 #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