source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreCompositorManager.h @ 1812

Revision 1812, 6.4 KB checked in by gumbau, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __CompositorManager_H__
26#define __CompositorManager_H__
27
28#include "OgrePrerequisites.h"
29#include "OgreResourceManager.h"
30#include "OgreCompositor.h"
31#include "OgreRectangle2D.h"
32#include "OgreCompositorSerializer.h"
33
34namespace Ogre {
35    /** Class for managing Compositor settings for Ogre. Compositors provide the means
36        to flexibly "composite" the final rendering result from multiple scene renders
37        and intermediate operations like rendering fullscreen quads. This makes
38        it possible to apply postfilter effects, HDRI postprocessing, and shadow
39        effects to a Viewport.
40        @par
41            When loaded from a script, a Compositor is in an 'unloaded' state and only stores the settings
42            required. It does not at that stage load any textures. This is because the material settings may be
43            loaded 'en masse' from bulk material script files, but only a subset will actually be required.
44        @par
45            Because this is a subclass of ResourceManager, any files loaded will be searched for in any path or
46            archive added to the resource paths/archives. See ResourceManager for details.
47    */
48    class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
49    {
50    public:
51        CompositorManager();
52        virtual ~CompositorManager();
53
54        /// Overridden from ResourceManager
55        Resource* createImpl(const String& name, ResourceHandle handle,
56            const String& group, bool isManual, ManualResourceLoader* loader,
57            const NameValuePairList* params);
58
59        /** Intialises the Compositor manager, which also triggers it to
60            parse all available .compositor scripts. */
61        void initialise(void);
62
63        /** @see ScriptLoader::parseScript
64        */
65        void parseScript(DataStreamPtr& stream, const String& groupName);
66
67        /** Get the compositor chain for a Viewport. If there is none yet, a new
68                        compositor chain is registered.
69                        XXX We need a _notifyViewportRemoved to find out when this viewport disappears,
70                        so we can destroy its chain as well.
71        */
72        CompositorChain *getCompositorChain(Viewport *vp);
73
74                /** Returns whether exists compositor chain for a viewport.
75        */
76                bool hasCompositorChain(Viewport *vp) const;
77
78                /** Remove the compositor chain from a viewport if exists.
79                */
80        void removeCompositorChain(Viewport *vp);
81
82                /** Add a compositor to a viewport. By default, it is added to end of the chain,
83                        after the other compositors.
84                        @param vp                       Viewport to modify
85                        @param compositor       The name of the compositor to apply
86                        @param addPosition      At which position to add, defaults to the end (-1).
87                        @returns pointer to instance, or 0 if it failed.
88                */
89                CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1);
90
91                /** Remove a compositor from a viewport
92                */
93                void removeCompositor(Viewport *vp, const String &compositor);
94
95                /** Set the state of a compositor on a viewport to enabled or disabled.
96                        Disabling a compositor stops it from rendering but does not free any resources.
97                        This can be more efficient than using removeCompositor and addCompositor in cases
98                        the filter is switched on and off a lot.
99                */
100                void setCompositorEnabled(Viewport *vp, const String &compositor, bool value);
101
102                /** Get a textured fullscreen 2D rectangle, for internal use.
103                */
104                Renderable *_getTexturedRectangle2D();
105
106                /** Overridden from ResourceManager since we have to clean up chains too. */
107                void removeAll(void);
108
109                /** Override standard Singleton retrieval.
110                @remarks
111                Why do we do this? Well, it's because the Singleton
112                implementation is in a .h file, which means it gets compiled
113                into anybody who includes it. This is needed for the
114                Singleton template to work, but we actually only want it
115                compiled into the implementation of the class based on the
116                Singleton, not all of them. If we don't change this, we get
117                link errors when trying to use the Singleton-based class from
118                an outside dll.
119                @par
120                This method just delegates to the template version anyway,
121                but the implementation stays in this single compilation unit,
122                preventing link errors.
123                */
124                static CompositorManager& getSingleton(void);
125                /** Override standard Singleton retrieval.
126                @remarks
127                Why do we do this? Well, it's because the Singleton
128                implementation is in a .h file, which means it gets compiled
129                into anybody who includes it. This is needed for the
130                Singleton template to work, but we actually only want it
131                compiled into the implementation of the class based on the
132                Singleton, not all of them. If we don't change this, we get
133                link errors when trying to use the Singleton-based class from
134                an outside dll.
135                @par
136                This method just delegates to the template version anyway,
137                but the implementation stays in this single compilation unit,
138                preventing link errors.
139                */
140                static CompositorManager* getSingletonPtr(void);
141
142       
143        private:
144        typedef std::map<Viewport*, CompositorChain*> Chains;
145        Chains mChains;
146
147        /// Serializer
148        CompositorSerializer mSerializer;
149
150        /** Clear composition chains for all viewports
151         */
152        void freeChains();
153
154                Rectangle2D *mRectangle;
155    };
156}
157
158#endif
Note: See TracBrowser for help on using the repository browser.