OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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 
38 namespace Ogre {
58  class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
59  {
60  public:
62  virtual ~CompositorManager();
63 
65  Resource* createImpl(const String& name, ResourceHandle handle,
66  const String& group, bool isManual, ManualResourceLoader* loader,
67  const NameValuePairList* params);
68 
71  void initialise(void);
72 
75  void parseScript(DataStreamPtr& stream, const String& groupName);
76 
82  CompositorChain *getCompositorChain(Viewport *vp);
83 
86  bool hasCompositorChain(Viewport *vp) const;
87 
90  void removeCompositorChain(Viewport *vp);
91 
99  CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1);
100 
103  void removeCompositor(Viewport *vp, const String &compositor);
104 
110  void setCompositorEnabled(Viewport *vp, const String &compositor, bool value);
111 
114  Renderable *_getTexturedRectangle2D();
115 
117  void removeAll(void);
118 
120  void _reconstructAllCompositorResources();
121 
123 
131  TexturePtr getPooledTexture(const String& name, const String& localName,
132  size_t w, size_t h,
133  PixelFormat f, uint aa, const String& aaHint, bool srgb, UniqueTextureSet& texturesAlreadyAssigned,
135 
139  void freePooledTextures(bool onlyIfUnreferenced = true);
140 
144  void registerCompositorLogic(const String& name, CompositorLogic* logic);
145 
148  CompositorLogic* getCompositorLogic(const String& name);
149 
152  void registerCustomCompositionPass(const String& name, CustomCompositionPass* customPass);
153 
156  CustomCompositionPass* getCustomCompositionPass(const String& name);
157 
163  void _relocateChain(Viewport* sourceVP, Viewport* destVP);
164 
180  static CompositorManager& getSingleton(void);
196  static CompositorManager* getSingletonPtr(void);
197 
198 
199  private:
202 
205  void freeChains();
206 
208 
212 
216 
220 
223 
224  struct TextureDef
225  {
226  size_t width, height;
230  bool sRGBwrite;
231 
232  TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String& aaHint, bool srgb)
233  : width(w), height(h), format(f), fsaa(aa), fsaaHint(aaHint), sRGBwrite(srgb)
234  {
235 
236  }
237  };
239  {
240  bool _OgreExport operator()(const TextureDef& x, const TextureDef& y) const
241  {
242  if (x.format < y.format)
243  return true;
244  else if (x.format == y.format)
245  {
246  if (x.width < y.width)
247  return true;
248  else if (x.width == y.width)
249  {
250  if (x.height < y.height)
251  return true;
252  else if (x.height == y.height)
253  {
254  if (x.fsaa < y.fsaa)
255  return true;
256  else if (x.fsaa == y.fsaa)
257  {
258  if (x.fsaaHint < y.fsaaHint)
259  return true;
260  else if (x.fsaaHint == y.fsaaHint)
261  {
262  if (!x.sRGBwrite && y.sRGBwrite)
263  return true;
264  }
265 
266  }
267  }
268  }
269  }
270  return false;
271  }
272  virtual ~TextureDefLess() {}
273  };
276 
277  typedef std::pair<String, String> StringPair;
279  typedef std::map<StringPair, TextureDefMap> ChainTexturesByDef;
280 
282 
283  bool isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName);
284  bool isInputPreviousTarget(CompositorInstance* inst, TexturePtr tex);
285  bool isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName);
286  bool isInputToOutputTarget(CompositorInstance* inst, TexturePtr tex);
287 
288  };
292 }
293 
294 #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:203
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:524
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
Interface describing a manual resource loader.
Definition: OgreResource.h:512
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.
Specialisation of SharedPtr to allow SharedPtr to be assigned to TexturePtr.
Definition: OgreTexture.h:440
ChainTexturesByDef mChainTexturesByDef
std::map< K, V, P, A > type
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
vector< TexturePtr >::type TextureList
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:56
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.
_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.
std::map< StringPair, TextureDefMap > ChainTexturesByDef
CompositorLogicMap mCompositorLogics
unsigned int uint