OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreCompositorManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE 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 
39 namespace Ogre {
59  class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
60  {
61  public:
63  virtual ~CompositorManager();
64 
66  Resource* createImpl(const String& name, ResourceHandle handle,
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 
84  CompositorPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
85 
86 
89  void parseScript(DataStreamPtr& stream, const String& groupName);
90 
96  CompositorChain *getCompositorChain(Viewport *vp);
97 
100  bool hasCompositorChain(Viewport *vp) const;
101 
104  void removeCompositorChain(Viewport *vp);
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 
128  Renderable *_getTexturedRectangle2D();
129 
131  void removeAll(void);
132 
134  void _reconstructAllCompositorResources();
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 
158  void registerCompositorLogic(const String& name, CompositorLogic* logic);
159 
162  void unregisterCompositorLogic(const String& name);
163 
166  CompositorLogic* getCompositorLogic(const String& name);
167 
170  void registerCustomCompositionPass(const String& name, CustomCompositionPass* customPass);
171 
174  CustomCompositionPass* getCustomCompositionPass(const String& name);
175 
191  static CompositorManager& getSingleton(void);
207  static CompositorManager* getSingletonPtr(void);
208 
209 
210  private:
213 
216  void freeChains();
217 
219 
223 
227 
231 
234 
235  struct TextureDef
236  {
237  size_t width, height;
241  bool sRGBwrite;
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 
294  bool isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName);
295  bool isInputPreviousTarget(CompositorInstance* inst, TexturePtr tex);
296  bool isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName);
297  bool isInputToOutputTarget(CompositorInstance* inst, TexturePtr tex);
298 
299  };
303 }
304 
305 #include "OgreHeaderSuffix.h"
306 
307 #endif
Chain of compositor effects applying to one viewport.
map< TextureDef, TexturePtr, TextureDefLess >::type TextureDefMap
CustomCompositionPassMap mCustomCompositionPasses
std::pair< String, String > StringPair
#define _OgreExport
Definition: OgrePlatform.h:260
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Interface for compositor logics, which can be automatically binded to compositors, allowing per-compositor logic (such as attaching a relevant listener) to happen automatically.
map< TextureDef, TextureList *, TextureDefLess >::type TexturesByDef
VectorIterator< TextureList > TextureIterator
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
map< StringPair, TextureDefMap >::type ChainTexturesByDef
Interface describing a manual resource loader.
Definition: OgreResource.h:514
vector< CompositorInstance * >::type Instances
List of instances.
map< String, CompositorLogic * >::type CompositorLogicMap
Map of registered compositor logics.
Abstract class defining the interface all renderable objects must implement.
std::set< T, P, A > type
map< String, CustomCompositionPass * >::type CustomCompositionPassMap
Map of registered custom composition passes.
Allows the rendering of a simple 2D rectangle This class renders a simple 2D rectangle; this rectangl...
PixelFormat
The pixel format used for images, textures, and render surfaces.
ChainTexturesByDef mChainTexturesByDef
std::map< K, V, P, A > type
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
vector< TexturePtr >::type TextureList
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
Class for managing Compositor settings for Ogre.
set< Texture * >::type UniqueTextureSet
bool _OgreExport operator()(const TextureDef &x, const TextureDef &y) const
An instance of a Compositor object for one Viewport.
TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String &aaHint, bool srgb)
Defines a generic resource handler.
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
Interface for custom composition passes, allowing custom operations (in addition to the quad...
map< Viewport *, CompositorChain * >::type Chains
Concrete IteratorWrapper for nonconst access to the underlying container.
CompositorLogicMap mCompositorLogics
unsigned int uint