# OgreCompositorManager.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 __CompositorManager_H__
    00029 #define __CompositorManager_H__
    00030
    00031 #include "OgrePrerequisites.h"
    00032 #include "OgreResourceManager.h"
    00033 #include "OgreCompositor.h"
    00034 #include "OgreRectangle2D.h"
    00035 #include "OgreRenderSystem.h"
    00036 #include "OgreCompositionTechnique.h"
    00037
    00038 namespace Ogre {
    00058     class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
    00059     {
    00060     public:
    00061         CompositorManager();
    00062         virtual ~CompositorManager();
    00063
    00065         Resource* createImpl(const String& name, ResourceHandle handle,
    00066             const String& group, bool isManual, ManualResourceLoader* loader,
    00067             const NameValuePairList* params);
    00068
    00071         void initialise(void);
    00072
    00075         void parseScript(DataStreamPtr& stream, const String& groupName);
    00076
    00082         CompositorChain *getCompositorChain(Viewport *vp);
    00083
    00086         bool hasCompositorChain(Viewport *vp) const;
    00087
    00090         void removeCompositorChain(Viewport *vp);
    00091
    00099         CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1);
    00100
    00103         void removeCompositor(Viewport *vp, const String &compositor);
    00104
    00110         void setCompositorEnabled(Viewport *vp, const String &compositor, bool value);
    00111
    00114         Renderable *_getTexturedRectangle2D();
    00115
    00117         void removeAll(void);
    00118
    00120         void _reconstructAllCompositorResources();
    00121
    00122         typedef set<Texture*>::type UniqueTextureSet;
    00123
    00131         TexturePtr getPooledTexture(const String& name, const String& localName,
    00132             size_t w, size_t h,
    00133             PixelFormat f, uint aa, const String& aaHint, bool srgb, UniqueTextureSet& texturesAlreadyAssigned,
    00134             CompositorInstance* inst, CompositionTechnique::TextureScope scope);
    00135
    00139         void freePooledTextures(bool onlyIfUnreferenced = true);
    00140
    00144         void registerCompositorLogic(const String& name, CompositorLogic* logic);
    00145
    00148         CompositorLogic* getCompositorLogic(const String& name);
    00149
    00152         void registerCustomCompositionPass(const String& name, CustomCompositionPass* customPass);
    00153
    00156         CustomCompositionPass* getCustomCompositionPass(const String& name);
    00157
    00163         void _relocateChain(Viewport* sourceVP, Viewport* destVP);
    00164
    00180         static CompositorManager& getSingleton(void);
    00196         static CompositorManager* getSingletonPtr(void);
    00197
    00198
    00199     private:
    00200         typedef map<Viewport*, CompositorChain*>::type Chains;
    00201         Chains mChains;
    00202
    00205         void freeChains();
    00206
    00207         Rectangle2D *mRectangle;
    00208
    00210         typedef vector<CompositorInstance *>::type Instances;
    00211         Instances mInstances;
    00212
    00214         typedef map<String, CompositorLogic*>::type CompositorLogicMap;
    00215         CompositorLogicMap mCompositorLogics;
    00216
    00218         typedef map<String, CustomCompositionPass*>::type CustomCompositionPassMap;
    00219         CustomCompositionPassMap mCustomCompositionPasses;
    00220
    00221         typedef vector<TexturePtr>::type TextureList;
    00222         typedef VectorIterator<TextureList> TextureIterator;
    00223
    00224         struct TextureDef
    00225         {
    00226             size_t width, height;
    00227             PixelFormat format;
    00228             uint fsaa;
    00229             String fsaaHint;
    00230             bool sRGBwrite;
    00231
    00232             TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String& aaHint, bool srgb)
    00233                 : width(w), height(h), format(f), fsaa(aa), fsaaHint(aaHint), sRGBwrite(srgb)
    00234             {
    00235
    00236             }
    00237         };
    00238         struct TextureDefLess
    00239         {
    00240             bool _OgreExport operator()(const TextureDef& x, const TextureDef& y) const
    00241             {
    00242                 if (x.format < y.format)
    00243                     return true;
    00244                 else if (x.format == y.format)
    00245                 {
    00246                     if (x.width < y.width)
    00247                         return true;
    00248                     else if (x.width == y.width)
    00249                     {
    00250                         if (x.height < y.height)
    00251                             return true;
    00252                         else if (x.height == y.height)
    00253                         {
    00254                             if (x.fsaa < y.fsaa)
    00255                                 return true;
    00256                             else if (x.fsaa == y.fsaa)
    00257                             {
    00258                                 if (x.fsaaHint < y.fsaaHint)
    00259                                     return true;
    00260                                 else if (x.fsaaHint == y.fsaaHint)
    00261                                 {
    00262                                     if (!x.sRGBwrite && y.sRGBwrite)
    00263                                         return true;
    00264                                 }
    00265
    00266                             }
    00267                         }
    00268                     }
    00269                 }
    00270                 return false;
    00271             }
    00272             virtual ~TextureDefLess() {}
    00273         };
    00274         typedef map<TextureDef, TextureList*, TextureDefLess>::type TexturesByDef;
    00275         TexturesByDef mTexturesByDef;
    00276
    00277         typedef std::pair<String, String> StringPair;
    00278         typedef map<TextureDef, TexturePtr, TextureDefLess>::type TextureDefMap;
    00279         typedef std::map<StringPair, TextureDefMap> ChainTexturesByDef;
    00280
    00281         ChainTexturesByDef mChainTexturesByDef;
    00282
    00283         bool isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName);
    00284         bool isInputPreviousTarget(CompositorInstance* inst, TexturePtr tex);
    00285         bool isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName);
    00286         bool isInputToOutputTarget(CompositorInstance* inst, TexturePtr tex);
    00287
    00288     };
    00292 }
    00293
    00294 #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