OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreCompositorInstance.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 __CompositorInstance_H__
29 #define __CompositorInstance_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreMaterialManager.h"
33 #include "OgreTexture.h"
34 #include "OgreRenderQueue.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
46 
51  {
52  public:
54  virtual ~CompositorInstance();
59  {
60  public:
61  virtual ~Listener();
62 
74  virtual void notifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
75 
86  virtual void notifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
87 
92  virtual void notifyResourcesCreated(bool forResizeOnly);
93 
94  };
100  {
101  public:
102  virtual ~RenderSystemOperation();
104  virtual void execute(SceneManager *sm, RenderSystem *rs) = 0;
105  };
107  typedef std::pair<int, RenderSystemOperation*> RenderSystemOpPair;
112  {
113  public:
115  {
116  }
118  target(inTarget), currentQueueGroupID(0), visibilityMask(0xFFFFFFFF),
119  lodBias(1.0f),
120  onlyInitial(false), hasBeenRendered(false), findVisibleObjects(false),
121  materialScheme(MaterialManager::DEFAULT_SCHEME_NAME), shadowsEnabled(true)
122  {
123  }
126 
129 
133 
137 
140  float lodBias;
141 
144  typedef std::bitset<RENDER_QUEUE_COUNT> RenderQueueBitSet;
145 
148 
163  };
165 
170  void setEnabled(bool value);
171 
174  bool getEnabled() const { return mEnabled; }
175 
182  void setAlive(bool value);
183 
186  bool getAlive() const { return mAlive; }
187 
201  const String& getTextureInstanceName(const String& name, size_t mrtIndex);
202 
216  TexturePtr getTextureInstance(const String& name, size_t mrtIndex);
217 
224  RenderTarget* getRenderTarget(const String& name);
225 
226 
231  virtual void _compileTargetOperations(CompiledState &compiledState);
232 
236  virtual void _compileOutputOperation(TargetOperation &finalState);
237 
240  Compositor *getCompositor();
241 
244  CompositionTechnique *getTechnique();
245 
253  void setTechnique(CompositionTechnique* tech, bool reuseTextures = true);
254 
268  void setScheme(const String& schemeName, bool reuseTextures = true);
269 
271  const String& getScheme() const { return mTechnique ? mTechnique->getSchemeName() : StringUtil::BLANK; }
272 
278  void notifyResized();
279 
282  CompositorChain *getChain();
283 
289  void addListener(Listener *l);
290 
294  void removeListener(Listener *l);
295 
298  void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat);
299 
302  void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat);
303 
306  void _fireNotifyResourcesCreated(bool forResizeOnly);
307  private:
315  bool mEnabled;
317  bool mAlive;
330 
334 
337 
341  virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target);
342 
347  MaterialPtr createLocalMaterial(const String& srcName);
348 
351  void createResources(bool forResizeOnly);
352 
355  void freeResources(bool forResizeOnly, bool clearReserveTextures);
356 
359  RenderTarget *getTargetForTex(const String &name);
360 
367  const String &getSourceForTex(const String &name, size_t mrtIndex = 0);
368 
371  void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op);
372 
374  String getMRTTexLocalName(const String& baseName, size_t attachment);
375 
379  void deriveTextureRenderTargetOptions(const String& texname,
380  bool *hwGammaWrite, uint *fsaa, String* fsaaHint);
381 
383  void notifyCameraChanged(Camera* camera);
384 
385  friend class CompositorChain;
386  };
390 } // namespace Ogre
391 
392 #include "OgreHeaderSuffix.h"
393 
394 #endif // __CompositorInstance_H__
Chain of compositor effects applying to one viewport.
A 'canvas' which can receive the results of a rendering operation.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
CompositionTechnique * mTechnique
Composition technique used by this instance.
ReserveTextureMap mReserveTextures
Textures that are not currently in use, but that we want to keep for now, for example if we switch te...
map< String, MultiRenderTarget * >::type LocalMRTMap
Store a list of MRTs we've created.
unsigned int uint32
Definition: OgrePlatform.h:344
#define _OgreExport
Definition: OgrePlatform.h:260
bool shadowsEnabled
Whether shadows will be enabled.
vector< RenderSystemOpPair >::type RenderSystemOpPairs
Manages the organisation and rendering of a 'scene' i.e.
std::bitset< RENDER_QUEUE_COUNT > RenderQueueBitSet
A set of render queues to either include or exclude certain render queues.
bool hasBeenRendered
"Has been rendered" flag; used in combination with onlyInitial to determine whether to skip this targ...
String materialScheme
Which material scheme this op will use.
map< String, TexturePtr >::type LocalTextureMap
Map from name->local texture.
CompositorInstance * mPreviousInstance
Previous instance (set by chain).
Class representing a Compositor object.
bool mEnabled
Is this instance enabled?
map< int, MaterialPtr >::type QuadMaterialMap
RenderQueueBitSet renderQueues
Which renderqueues to render from scene.
CompositorChain * mChain
Composition chain of which this instance is part.
Class for managing Material settings for Ogre.
Provides an interface to "listen in" to to render system operations executed by this CompositorInstan...
Compositor * mCompositor
Compositor of which this is an instance.
const String & getScheme() const
Returns the name of the scheme this compositor is using.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
bool getEnabled() const
Get enabled flag.
bool findVisibleObjects
Whether this op needs to find visible scene objects or not.
vector< TargetOperation >::type CompiledState
const size_t RENDER_QUEUE_COUNT
RenderSystemOpPairs renderSystemOperations
RenderSystem operations to queue into the scene manager, by uint8.
Base composition technique, can be subclassed in plugins.
std::map< K, V, P, A > type
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
bool mAlive
Is this instance allocating resources?
An instance of a Compositor object for one Viewport.
uint32 visibilityMask
Scene visibility mask If this is 0, the scene is not rendered at all.
Operation setup for a RenderTarget (collected).
vector< Listener * >::type Listeners
Vector of listeners.
Final possible render queue, don't exceed this.
_StringBase String
bool getAlive() const
Get alive flag.
Defines the functionality of a 3D API.
std::pair< int, RenderSystemOperation * > RenderSystemOpPair
unsigned int uint
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework...
map< CompositionTechnique::TextureDefinition *, TexturePtr >::type ReserveTextureMap