OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreCompositor.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 __Compositor_H__
29 #define __Compositor_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreIteratorWrappers.h"
33 #include "OgreResource.h"
34 #include "OgreTexture.h"
35 
36 namespace Ogre {
50  {
51  public:
52  Compositor(ResourceManager* creator, const String& name, ResourceHandle handle,
53  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
54  ~Compositor();
55 
59 
62  CompositionTechnique *createTechnique();
63 
66  void removeTechnique(size_t idx);
67 
70  CompositionTechnique *getTechnique(size_t idx);
71 
74  size_t getNumTechniques();
75 
78  void removeAllTechniques();
79 
81  TechniqueIterator getTechniqueIterator(void);
82 
89  CompositionTechnique *getSupportedTechnique(size_t idx);
90 
97  size_t getNumSupportedTechniques();
98 
105  TechniqueIterator getSupportedTechniqueIterator(void);
106 
114  CompositionTechnique *getSupportedTechnique(const String& schemeName = StringUtil::BLANK);
115 
121  const String& getTextureInstanceName(const String& name, size_t mrtIndex);
122 
128  TexturePtr getTextureInstance(const String& name, size_t mrtIndex);
129 
136  RenderTarget* getRenderTarget(const String& name);
137 
138  protected:
140  void loadImpl(void);
141 
143  void unloadImpl(void);
145  size_t calculateSize(void) const;
146 
149  void compile();
150  private:
153 
158 
161  void createGlobalTextures();
162 
165  void freeGlobalTextures();
166 
167  //TODO GSOC : These typedefs are duplicated from CompositorInstance. Solve?
174  };
175 
182  class _OgreExport CompositorPtr : public SharedPtr<Compositor>
183  {
184  public:
186  explicit CompositorPtr(Compositor* rep) : SharedPtr<Compositor>(rep) {}
189  {
190  // lock & copy other mutex pointer
191  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
192  {
193  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
194  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
195  pRep = static_cast<Compositor*>(r.getPointer());
196  pUseCount = r.useCountPointer();
197  if (pUseCount)
198  {
199  ++(*pUseCount);
200  }
201  }
202  }
203 
206  {
207  if (pRep == static_cast<Compositor*>(r.getPointer()))
208  return *this;
209  release();
210  // lock & copy other mutex pointer
211  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
212  {
213  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
214  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
215  pRep = static_cast<Compositor*>(r.getPointer());
216  pUseCount = r.useCountPointer();
217  if (pUseCount)
218  {
219  ++(*pUseCount);
220  }
221  }
222  else
223  {
224  // RHS must be a null pointer
225  assert(r.isNull() && "RHS must be null if it has no mutex!");
226  setNull();
227  }
228  return *this;
229  }
230  };
233 }
234 
235 #endif
Techniques mSupportedTechniques
A 'canvas' which can receive the results of a rendering operation.
T * getPointer() const
#define _OgreExport
Definition: OgrePlatform.h:233
vector< CompositionTechnique * >::type Techniques
Data types for internal lists.
Specialisation of SharedPtr to allow SharedPtr to be assigned to CompositorPtr.
#define OGRE_MUTEX_CONDITIONAL(name)
map< String, MultiRenderTarget * >::type GlobalMRTMap
Store a list of MRTs we've created.
Interface describing a manual resource loader.
Definition: OgreResource.h:513
Class representing a Compositor object.
GlobalTextureMap mGlobalTextures
CompositorPtr(const CompositorPtr &r)
Techniques mTechniques
VectorIterator< Techniques > TechniqueIterator
Specialisation of SharedPtr to allow SharedPtr to be assigned to TexturePtr.
Definition: OgreTexture.h:443
CompositorPtr(Compositor *rep)
CompositorPtr(const ResourcePtr &r)
Base composition technique, can be subclassed in plugins.
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:78
unsigned long long int ResourceHandle
Definition: OgreResource.h:40
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
#define OGRE_LOCK_MUTEX(name)
map< String, TexturePtr >::type GlobalTextureMap
Map from name->local texture.
bool mCompilationRequired
Compilation required This is set if the techniques change and the supportedness of techniques has to ...
Defines a generic resource handler.
unsigned int * useCountPointer() const
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:60
_StringBase String
Concrete IteratorWrapper for nonconst access to the underlying container.
GlobalMRTMap mGlobalMRTs
CompositorPtr & operator=(const ResourcePtr &r)
Operator used to convert a ResourcePtr to a CompositorPtr.
#define OGRE_COPY_AUTO_SHARED_MUTEX(from)
bool isNull(void) const