Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/OgreMain/include/OgreCompositorManager.h @ 20

Last change on this file since 20 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 6.7 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __CompositorManager_H__
30#define __CompositorManager_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreResourceManager.h"
34#include "OgreCompositor.h"
35#include "OgreRectangle2D.h"
36#include "OgreCompositorSerializer.h"
37
38#if OGRE_THREAD_SUPPORT
39// boost::thread_specific_ptr has 'new' in header but delete in lib
40// so if we use our memory manager it reports leaks incorrectly
41#       include "OgreNoMemoryMacros.h"
42#       include <boost/thread/tss.hpp>
43#       include "OgreMemoryMacros.h"
44#endif
45
46namespace Ogre {
47    /** Class for managing Compositor settings for Ogre. Compositors provide the means
48        to flexibly "composite" the final rendering result from multiple scene renders
49        and intermediate operations like rendering fullscreen quads. This makes
50        it possible to apply postfilter effects, HDRI postprocessing, and shadow
51        effects to a Viewport.
52        @par
53            When loaded from a script, a Compositor is in an 'unloaded' state and only stores the settings
54            required. It does not at that stage load any textures. This is because the material settings may be
55            loaded 'en masse' from bulk material script files, but only a subset will actually be required.
56        @par
57            Because this is a subclass of ResourceManager, any files loaded will be searched for in any path or
58            archive added to the resource paths/archives. See ResourceManager for details.
59    */
60    class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
61    {
62    public:
63        CompositorManager();
64        virtual ~CompositorManager();
65
66        /// Overridden from ResourceManager
67        Resource* createImpl(const String& name, ResourceHandle handle,
68            const String& group, bool isManual, ManualResourceLoader* loader,
69            const NameValuePairList* params);
70
71        /** Intialises the Compositor manager, which also triggers it to
72            parse all available .compositor scripts. */
73        void initialise(void);
74
75        /** @see ScriptLoader::parseScript
76        */
77        void parseScript(DataStreamPtr& stream, const String& groupName);
78
79        /** Get the compositor chain for a Viewport. If there is none yet, a new
80                        compositor chain is registered.
81                        XXX We need a _notifyViewportRemoved to find out when this viewport disappears,
82                        so we can destroy its chain as well.
83        */
84        CompositorChain *getCompositorChain(Viewport *vp);
85
86                /** Returns whether exists compositor chain for a viewport.
87        */
88                bool hasCompositorChain(Viewport *vp) const;
89
90                /** Remove the compositor chain from a viewport if exists.
91                */
92        void removeCompositorChain(Viewport *vp);
93
94                /** Add a compositor to a viewport. By default, it is added to end of the chain,
95                        after the other compositors.
96                        @param vp                       Viewport to modify
97                        @param compositor       The name of the compositor to apply
98                        @param addPosition      At which position to add, defaults to the end (-1).
99                        @returns pointer to instance, or 0 if it failed.
100                */
101                CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1);
102
103                /** Remove a compositor from a viewport
104                */
105                void removeCompositor(Viewport *vp, const String &compositor);
106
107                /** Set the state of a compositor on a viewport to enabled or disabled.
108                        Disabling a compositor stops it from rendering but does not free any resources.
109                        This can be more efficient than using removeCompositor and addCompositor in cases
110                        the filter is switched on and off a lot.
111                */
112                void setCompositorEnabled(Viewport *vp, const String &compositor, bool value);
113
114                /** Get a textured fullscreen 2D rectangle, for internal use.
115                */
116                Renderable *_getTexturedRectangle2D();
117
118                /** Overridden from ResourceManager since we have to clean up chains too. */
119                void removeAll(void);
120
121                /** Override standard Singleton retrieval.
122                @remarks
123                Why do we do this? Well, it's because the Singleton
124                implementation is in a .h file, which means it gets compiled
125                into anybody who includes it. This is needed for the
126                Singleton template to work, but we actually only want it
127                compiled into the implementation of the class based on the
128                Singleton, not all of them. If we don't change this, we get
129                link errors when trying to use the Singleton-based class from
130                an outside dll.
131                @par
132                This method just delegates to the template version anyway,
133                but the implementation stays in this single compilation unit,
134                preventing link errors.
135                */
136                static CompositorManager& getSingleton(void);
137                /** Override standard Singleton retrieval.
138                @remarks
139                Why do we do this? Well, it's because the Singleton
140                implementation is in a .h file, which means it gets compiled
141                into anybody who includes it. This is needed for the
142                Singleton template to work, but we actually only want it
143                compiled into the implementation of the class based on the
144                Singleton, not all of them. If we don't change this, we get
145                link errors when trying to use the Singleton-based class from
146                an outside dll.
147                @par
148                This method just delegates to the template version anyway,
149                but the implementation stays in this single compilation unit,
150                preventing link errors.
151                */
152                static CompositorManager* getSingletonPtr(void);
153
154       
155        private:
156        typedef std::map<Viewport*, CompositorChain*> Chains;
157        Chains mChains;
158
159                /// Serializer - Hold instance per thread if necessary
160                OGRE_THREAD_POINTER(CompositorSerializer, mSerializer);
161
162        /** Clear composition chains for all viewports
163         */
164        void freeChains();
165
166                Rectangle2D *mRectangle;
167    };
168}
169
170#endif
Note: See TracBrowser for help on using the repository browser.