# OgreCompositor.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 __Compositor_H__
    00029 #define __Compositor_H__
    00030
    00031 #include "OgrePrerequisites.h"
    00032 #include "OgreIteratorWrappers.h"
    00033 #include "OgreResource.h"
    00034 #include "OgreTexture.h"
    00035
    00036 namespace Ogre {
    00049     class _OgreExport Compositor: public Resource
    00050     {
    00051     public:
    00052         Compositor(ResourceManager* creator, const String& name, ResourceHandle handle,
    00053             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
    00054         ~Compositor();
    00055
    00057         typedef vector<CompositionTechnique *>::type Techniques;
    00058         typedef VectorIterator<Techniques> TechniqueIterator;
    00059
    00062         CompositionTechnique *createTechnique();
    00063
    00066         void removeTechnique(size_t idx);
    00067
    00070         CompositionTechnique *getTechnique(size_t idx);
    00071
    00074         size_t getNumTechniques();
    00075
    00078         void removeAllTechniques();
    00079
    00081         TechniqueIterator getTechniqueIterator(void);
    00082
    00089         CompositionTechnique *getSupportedTechnique(size_t idx);
    00090
    00097         size_t getNumSupportedTechniques();
    00098
    00105         TechniqueIterator getSupportedTechniqueIterator(void);
    00106
    00114         CompositionTechnique *getSupportedTechnique(const String& schemeName = StringUtil::BLANK);
    00115
    00121         const String& getTextureInstanceName(const String& name, size_t mrtIndex);
    00122
    00128         TexturePtr getTextureInstance(const String& name, size_t mrtIndex);
    00129
    00136         RenderTarget* getRenderTarget(const String& name);
    00137
    00138     protected:
    00140         void loadImpl(void);
    00141
    00143         void unloadImpl(void);
    00145         size_t calculateSize(void) const;
    00146
    00149         void compile();
    00150     private:
    00151         Techniques mTechniques;
    00152         Techniques mSupportedTechniques;
    00153
    00157         bool mCompilationRequired;
    00158
    00161         void createGlobalTextures();
    00162
    00165         void freeGlobalTextures();
    00166
    00167         //TODO GSOC : These typedefs are duplicated from CompositorInstance. Solve?
    00169         typedef map<String,TexturePtr>::type GlobalTextureMap;
    00170         GlobalTextureMap mGlobalTextures;
    00172         typedef map<String,MultiRenderTarget*>::type GlobalMRTMap;
    00173         GlobalMRTMap mGlobalMRTs;
    00174     };
    00175
    00182     class _OgreExport CompositorPtr : public SharedPtr<Compositor>
    00183     {
    00184     public:
    00185         CompositorPtr() : SharedPtr<Compositor>() {}
    00186         explicit CompositorPtr(Compositor* rep) : SharedPtr<Compositor>(rep) {}
    00187         CompositorPtr(const CompositorPtr& r) : SharedPtr<Compositor>(r) {}
    00188         CompositorPtr(const ResourcePtr& r) : SharedPtr<Compositor>()
    00189         {
    00190             // lock & copy other mutex pointer
    00191             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00192             {
    00193                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00194                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00195                 pRep = static_cast<Compositor*>(r.getPointer());
    00196                 pUseCount = r.useCountPointer();
    00197                 if (pUseCount)
    00198                 {
    00199                     ++(*pUseCount);
    00200                 }
    00201             }
    00202         }
    00203
    00205         CompositorPtr& operator=(const ResourcePtr& r)
    00206         {
    00207             if (pRep == static_cast<Compositor*>(r.getPointer()))
    00208                 return *this;
    00209             release();
    00210             // lock & copy other mutex pointer
    00211             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00212             {
    00213                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00214                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00215                 pRep = static_cast<Compositor*>(r.getPointer());
    00216                 pUseCount = r.useCountPointer();
    00217                 if (pUseCount)
    00218                 {
    00219                     ++(*pUseCount);
    00220                 }
    00221             }
    00222             else
    00223             {
    00224                 // RHS must be a null pointer
    00225                 assert(r.isNull() && "RHS must be null if it has no mutex!");
    00226                 setNull();
    00227             }
    00228             return *this;
    00229         }
    00230     };
    00233 }
    00234
    00235 #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