OGRE  1.8
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-2013 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  void unregisterCompositorLogic(const String& name);
149 
152  CompositorLogic* getCompositorLogic(const String& name);
153 
156  void registerCustomCompositionPass(const String& name, CustomCompositionPass* customPass);
157 
160  CustomCompositionPass* getCustomCompositionPass(const String& name);
161 
177  static CompositorManager& getSingleton(void);
193  static CompositorManager* getSingletonPtr(void);
194 
195 
196  private:
199 
202  void freeChains();
203 
205 
209 
213 
217 
220 
221  struct TextureDef
222  {
223  size_t width, height;
227  bool sRGBwrite;
228 
229  TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String& aaHint, bool srgb)
230  : width(w), height(h), format(f), fsaa(aa), fsaaHint(aaHint), sRGBwrite(srgb)
231  {
232 
233  }
234  };
236  {
237  bool _OgreExport operator()(const TextureDef& x, const TextureDef& y) const
238  {
239  if (x.format < y.format)
240  return true;
241  else if (x.format == y.format)
242  {
243  if (x.width < y.width)
244  return true;
245  else if (x.width == y.width)
246  {
247  if (x.height < y.height)
248  return true;
249  else if (x.height == y.height)
250  {
251  if (x.fsaa < y.fsaa)
252  return true;
253  else if (x.fsaa == y.fsaa)
254  {
255  if (x.fsaaHint < y.fsaaHint)
256  return true;
257  else if (x.fsaaHint == y.fsaaHint)
258  {
259  if (!x.sRGBwrite && y.sRGBwrite)
260  return true;
261  }
262 
263  }
264  }
265  }
266  }
267  return false;
268  }
269  virtual ~TextureDefLess() {}
270  };
273 
274  typedef std::pair<String, String> StringPair;
276  typedef std::map<StringPair, TextureDefMap> ChainTexturesByDef;
277 
279 
280  bool isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName);
281  bool isInputPreviousTarget(CompositorInstance* inst, TexturePtr tex);
282  bool isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName);
283  bool isInputToOutputTarget(CompositorInstance* inst, TexturePtr tex);
284 
285  };
289 }
290 
291 #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:233
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
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:513
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:443
ChainTexturesByDef mChainTexturesByDef
std::map< K, V, P, A > type
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:78
unsigned long long int ResourceHandle
Definition: OgreResource.h:40
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