OgreCompositorManager.h
Go to the documentation of this file.
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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __CompositorManager_H__
29#define __CompositorManager_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreResourceManager.h"
33#include "OgreCompositor.h"
34#include "OgreRectangle2D.h"
35#include "OgreRenderSystem.h"
37#include "OgreHeaderPrefix.h"
38
39namespace Ogre {
59 class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
60 {
61 public:
64
67 const String& group, bool isManual, ManualResourceLoader* loader,
68 const NameValuePairList* params);
69
72 void initialise(void);
73
78 CompositorPtr create (const String& name, const String& group,
79 bool isManual = false, ManualResourceLoader* loader = 0,
80 const NameValuePairList* createParams = 0);
81
85
86
89 void parseScript(DataStreamPtr& stream, const String& groupName);
90
97
101
105
113 CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1);
114
117 void removeCompositor(Viewport *vp, const String &compositor);
118
124 void setCompositorEnabled(Viewport *vp, const String &compositor, bool value);
125
129
131 void removeAll(void);
132
135
137
145 TexturePtr getPooledTexture(const String& name, const String& localName,
146 size_t w, size_t h,
147 PixelFormat f, uint aa, const String& aaHint, bool srgb, UniqueTextureSet& texturesAlreadyAssigned,
149
153 void freePooledTextures(bool onlyIfUnreferenced = true);
154
159
163
167
171
175
208
209
210 private:
213
217
219
223
227
231
234
236 {
237 size_t width, height;
242
243 TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String& aaHint, bool srgb)
244 : width(w), height(h), format(f), fsaa(aa), fsaaHint(aaHint), sRGBwrite(srgb)
245 {
246
247 }
248 };
250 {
251 bool _OgreExport operator()(const TextureDef& x, const TextureDef& y) const
252 {
253 if (x.format < y.format)
254 return true;
255 else if (x.format == y.format)
256 {
257 if (x.width < y.width)
258 return true;
259 else if (x.width == y.width)
260 {
261 if (x.height < y.height)
262 return true;
263 else if (x.height == y.height)
264 {
265 if (x.fsaa < y.fsaa)
266 return true;
267 else if (x.fsaa == y.fsaa)
268 {
269 if (x.fsaaHint < y.fsaaHint)
270 return true;
271 else if (x.fsaaHint == y.fsaaHint)
272 {
273 if (!x.sRGBwrite && y.sRGBwrite)
274 return true;
275 }
276
277 }
278 }
279 }
280 }
281 return false;
282 }
283 virtual ~TextureDefLess() {}
284 };
287
288 typedef std::pair<String, String> StringPair;
291
293
298
299 };
303}
304
305#include "OgreHeaderSuffix.h"
306
307#endif
#define _OgreExport
Definition: OgrePlatform.h:257
Chain of compositor effects applying to one viewport.
An instance of a Compositor object for one Viewport.
Interface for compositor logics, which can be automatically binded to compositors,...
Class for managing Compositor settings for Ogre.
static CompositorManager & getSingleton(void)
Override standard Singleton retrieval.
CompositorLogic * getCompositorLogic(const String &name)
Get a compositor logic by its name.
void freePooledTextures(bool onlyIfUnreferenced=true)
Free pooled textures from the shared pool (compositor instances still using them will keep them in me...
CustomCompositionPass * getCustomCompositionPass(const String &name)
Get a custom composition pass by its name.
bool isInputToOutputTarget(CompositorInstance *inst, TexturePtr tex)
void parseScript(DataStreamPtr &stream, const String &groupName)
void setCompositorEnabled(Viewport *vp, const String &compositor, bool value)
Set the state of a compositor on a viewport to enabled or disabled.
map< Viewport *, CompositorChain * >::type Chains
void removeAll(void)
Overridden from ResourceManager since we have to clean up chains too.
static CompositorManager * getSingletonPtr(void)
Override standard Singleton retrieval.
vector< TexturePtr >::type TextureList
void _reconstructAllCompositorResources()
Internal method for forcing all active compositors to recreate their resources.
bool isInputPreviousTarget(CompositorInstance *inst, TexturePtr tex)
vector< CompositorInstance * >::type Instances
List of instances.
std::pair< String, String > StringPair
CustomCompositionPassMap mCustomCompositionPasses
VectorIterator< TextureList > TextureIterator
map< StringPair, TextureDefMap >::type ChainTexturesByDef
map< TextureDef, TextureList *, TextureDefLess >::type TexturesByDef
set< Texture * >::type UniqueTextureSet
void removeCompositor(Viewport *vp, const String &compositor)
Remove a compositor from a viewport.
void registerCompositorLogic(const String &name, CompositorLogic *logic)
Register a compositor logic for listening in to expecting composition techniques.
void unregisterCompositorLogic(const String &name)
Removes a listener for compositor logic registered with registerCompositorLogic.
map< String, CustomCompositionPass * >::type CustomCompositionPassMap
Map of registered custom composition passes.
bool isInputToOutputTarget(CompositorInstance *inst, const Ogre::String &localName)
CompositorPtr create(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0)
Create a new compositor.
map< String, CompositorLogic * >::type CompositorLogicMap
Map of registered compositor logics.
CompositorChain * getCompositorChain(Viewport *vp)
Get the compositor chain for a Viewport.
ChainTexturesByDef mChainTexturesByDef
CompositorInstance * addCompositor(Viewport *vp, const String &compositor, int addPosition=-1)
Add a compositor to a viewport.
Renderable * _getTexturedRectangle2D()
Get a textured fullscreen 2D rectangle, for internal use.
CompositorLogicMap mCompositorLogics
void removeCompositorChain(Viewport *vp)
Remove the compositor chain from a viewport if exists.
bool hasCompositorChain(Viewport *vp) const
Returns whether exists compositor chain for a viewport.
CompositorPtr getByName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Get a resource by name.
void initialise(void)
Initialises the Compositor manager, which also triggers it to parse all available ....
void freeChains()
Clear composition chains for all viewports.
void registerCustomCompositionPass(const String &name, CustomCompositionPass *customPass)
Register a custom composition pass.
bool isInputPreviousTarget(CompositorInstance *inst, const Ogre::String &localName)
map< TextureDef, TexturePtr, TextureDefLess >::type TextureDefMap
Resource * createImpl(const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, const NameValuePairList *params)
Overridden from ResourceManager.
TexturePtr getPooledTexture(const String &name, const String &localName, size_t w, size_t h, PixelFormat f, uint aa, const String &aaHint, bool srgb, UniqueTextureSet &texturesAlreadyAssigned, CompositorInstance *inst, CompositionTechnique::TextureScope scope)
Utility function to get an existing pooled texture matching a given definition, or creating one if on...
Interface for custom composition passes, allowing custom operations (in addition to the quad,...
Interface describing a manual resource loader.
Definition: OgreResource.h:515
Allows the rendering of a simple 2D rectangle This class renders a simple 2D rectangle; this rectangl...
Abstract class defining the interface all renderable objects must implement.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Defines a generic resource handler.
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:80
Reference-counted shared pointer, used for objects where implicit destruction is required.
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:65
Concrete IteratorWrapper for nonconst access to the underlying container.
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:58
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
PixelFormat
The pixel format used for images, textures, and render surfaces.
unsigned int uint
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
_StringBase String
bool _OgreExport operator()(const TextureDef &x, const TextureDef &y) const
TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String &aaHint, bool srgb)
std::map< K, V, P, A > type
std::set< T, P, A > type

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.