# OgreCompositorInstance.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 __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
    00163         void setEnabled(bool value);
    00164
    00167         bool getEnabled();
    00168
    00179         const String& getTextureInstanceName(const String& name, size_t mrtIndex);
    00180
    00191         TexturePtr getTextureInstance(const String& name, size_t mrtIndex);
    00192
    00199         RenderTarget* getRenderTarget(const String& name);
    00200
    00201
    00205         virtual void _compileTargetOperations(CompiledState &compiledState);
    00206
    00210         virtual void _compileOutputOperation(TargetOperation &finalState);
    00211
    00214         Compositor *getCompositor();
    00215
    00218         CompositionTechnique *getTechnique();
    00219
    00225         void setTechnique(CompositionTechnique* tech, bool reuseTextures = true);
    00226
    00238         void setScheme(const String& schemeName, bool reuseTextures = true);
    00239
    00241         const String& getScheme() const { return mActiveScheme; }
    00242
    00248         void notifyResized();
    00249
    00250
    00253         CompositorChain *getChain();
    00254
    00260         void addListener(Listener *l);
    00261
    00265         void removeListener(Listener *l);
    00266
    00269         void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
    00270
    00273         void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
    00274
    00277         void _fireNotifyResourcesCreated(bool forResizeOnly);
    00278     private:
    00280         Compositor *mCompositor;
    00282         CompositionTechnique *mTechnique;
    00284         CompositorChain *mChain;
    00286         bool mEnabled;
    00288         typedef map<String,TexturePtr>::type LocalTextureMap;
    00289         LocalTextureMap mLocalTextures;
    00291         typedef map<String,MultiRenderTarget*>::type LocalMRTMap;
    00292         LocalMRTMap mLocalMRTs;
    00293         typedef map<CompositionTechnique::TextureDefinition*, TexturePtr>::type ReserveTextureMap;
    00298         ReserveTextureMap mReserveTextures;
    00299
    00301         typedef vector<Listener*>::type Listeners;
    00302         Listeners mListeners;
    00303
    00305         CompositorInstance *mPreviousInstance;
    00306
    00308         String mActiveScheme;
    00309
    00313         virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target);
    00314
    00319         MaterialPtr createLocalMaterial(const String& srcName);
    00320
    00323         void createResources(bool forResizeOnly);
    00324
    00327         void freeResources(bool forResizeOnly, bool clearReserveTextures);
    00328
    00331         RenderTarget *getTargetForTex(const String &name);
    00332
    00337         const String &getSourceForTex(const String &name, size_t mrtIndex = 0);
    00338
    00342         void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op);
    00343
    00345         String getMRTTexLocalName(const String& baseName, size_t attachment);
    00346
    00350         void deriveTextureRenderTargetOptions(const String& texname,
    00351             bool *hwGammaWrite, uint *fsaa, String* fsaaHint);
    00352
    00353         friend class CompositorChain;
    00354     };
    00358 }
    00359
    00360 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun May 8 2011 20:28:08