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-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 __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:
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:
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 
225 
226 
231  virtual void _compileTargetOperations(CompiledState &compiledState);
232 
236  virtual void _compileOutputOperation(TargetOperation &finalState);
237 
241 
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 
279 
283 
290 
295 
299 
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 
348 
351  void createResources(bool forResizeOnly);
352 
355  void freeResources(bool forResizeOnly, bool clearReserveTextures);
356 
360 
367  const String &getSourceForTex(const String &name, size_t mrtIndex = 0);
368 
372 
374  String getMRTTexLocalName(const String& baseName, size_t attachment);
375 
380  bool *hwGammaWrite, uint *fsaa, String* fsaaHint);
381 
384 
385  friend class CompositorChain;
386  };
390 } // namespace Ogre
391 
392 #include "OgreHeaderSuffix.h"
393 
394 #endif // __CompositorInstance_H__
#define _OgreExport
Definition: OgrePlatform.h:257
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Object representing one render to a RenderTarget or Viewport in the Ogre Composition framework.
Base composition technique, can be subclassed in plugins.
Chain of compositor effects applying to one viewport.
Provides an interface to "listen in" to to render system operations executed by this CompositorInstan...
virtual void notifyMaterialRender(uint32 pass_id, MaterialPtr &mat)
Notification before a render target operation involving a material (like rendering a quad),...
virtual void notifyMaterialSetup(uint32 pass_id, MaterialPtr &mat)
Notification of when a render target operation involving a material (like rendering a quad) is compil...
virtual void notifyResourcesCreated(bool forResizeOnly)
Notification after resources have been created (or recreated).
virtual void execute(SceneManager *sm, RenderSystem *rs)=0
Set state to SceneManager and RenderSystem.
Operation setup for a RenderTarget (collected).
bool findVisibleObjects
Whether this op needs to find visible scene objects or not.
bool hasBeenRendered
"Has been rendered" flag; used in combination with onlyInitial to determine whether to skip this targ...
RenderQueueBitSet renderQueues
Which renderqueues to render from scene.
std::bitset< RENDER_QUEUE_COUNT > RenderQueueBitSet
A set of render queues to either include or exclude certain render queues.
RenderSystemOpPairs renderSystemOperations
RenderSystem operations to queue into the scene manager, by uint8.
uint32 visibilityMask
Scene visibility mask If this is 0, the scene is not rendered at all.
bool shadowsEnabled
Whether shadows will be enabled.
String materialScheme
Which material scheme this op will use.
An instance of a Compositor object for one Viewport.
void createResources(bool forResizeOnly)
Create local rendertextures and other resources.
void setScheme(const String &schemeName, bool reuseTextures=true)
Pick a technique to use to render this compositor based on a scheme.
const String & getTextureInstanceName(const String &name, size_t mrtIndex)
Get the instance name for a local texture.
map< String, TexturePtr >::type LocalTextureMap
Map from name->local texture.
void setEnabled(bool value)
Set enabled flag.
void deriveTextureRenderTargetOptions(const String &texname, bool *hwGammaWrite, uint *fsaa, String *fsaaHint)
Search for options like AA and hardware gamma which we may want to inherit from the main render targe...
void _fireNotifyMaterialRender(uint32 pass_id, MaterialPtr &mat)
Notify listeners of a material render.
CompositorInstance(CompositionTechnique *technique, CompositorChain *chain)
CompositionTechnique * getTechnique()
Get CompositionTechnique used by this instance.
CompositionTechnique * mTechnique
Composition technique used by this instance.
void setTechnique(CompositionTechnique *tech, bool reuseTextures=true)
Change the technique we're using to render this compositor.
bool mAlive
Is this instance allocating resources?
virtual void _compileOutputOperation(TargetOperation &finalState)
Compile the final (output) operation.
void _fireNotifyMaterialSetup(uint32 pass_id, MaterialPtr &mat)
Notify listeners of a material compilation.
TexturePtr getTextureInstance(const String &name, size_t mrtIndex)
Get the instance of a local texture.
const String & getSourceForTex(const String &name, size_t mrtIndex=0)
Get source texture name for a named local texture.
MaterialPtr createLocalMaterial(const String &srcName)
Create a local dummy material with one technique but no passes.
Compositor * getCompositor()
Get Compositor of which this is an instance.
virtual void collectPasses(TargetOperation &finalState, CompositionTargetPass *target)
Collect rendering passes.
void freeResources(bool forResizeOnly, bool clearReserveTextures)
Destroy local rendertextures and other resources.
map< String, MultiRenderTarget * >::type LocalMRTMap
Store a list of MRTs we've created.
RenderTarget * getRenderTarget(const String &name)
Get the render target for a given render texture name.
bool getAlive() const
Get alive flag.
const String & getScheme() const
Returns the name of the scheme this compositor is using.
ReserveTextureMap mReserveTextures
Textures that are not currently in use, but that we want to keep for now, for example if we switch te...
void queueRenderSystemOp(TargetOperation &finalState, RenderSystemOperation *op)
Queue a render system operation.
vector< Listener * >::type Listeners
Vector of listeners.
RenderTarget * getTargetForTex(const String &name)
Get RenderTarget for a named local texture.
virtual void _compileTargetOperations(CompiledState &compiledState)
Recursively collect target states (except for final Pass).
std::pair< int, RenderSystemOperation * > RenderSystemOpPair
String getMRTTexLocalName(const String &baseName, size_t attachment)
Util method for assigning a local texture name to a MRT attachment.
map< int, MaterialPtr >::type QuadMaterialMap
CompositorChain * mChain
Composition chain of which this instance is part.
bool getEnabled() const
Get enabled flag.
void setAlive(bool value)
Set alive/active flag.
void notifyCameraChanged(Camera *camera)
Notify this instance that the primary viewport's camera has changed.
CompositorInstance * mPreviousInstance
Previous instance (set by chain).
void addListener(Listener *l)
Add a listener.
map< CompositionTechnique::TextureDefinition *, TexturePtr >::type ReserveTextureMap
void notifyResized()
Notify this instance that the primary surface has been resized.
Compositor * mCompositor
Compositor of which this is an instance.
vector< RenderSystemOpPair >::type RenderSystemOpPairs
bool mEnabled
Is this instance enabled?
CompositorChain * getChain()
Get Chain that this instance is part of.
void _fireNotifyResourcesCreated(bool forResizeOnly)
Notify listeners of a material render.
void removeListener(Listener *l)
Remove a listener.
vector< TargetOperation >::type CompiledState
Class representing a Compositor object.
Class for managing Material settings for Ogre.
Defines the functionality of a 3D API.
A 'canvas' which can receive the results of a rendering operation.
Manages the organisation and rendering of a 'scene' i.e.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
const size_t RENDER_QUEUE_COUNT
@ RENDER_QUEUE_MAX
Final possible render queue, don't exceed this.
unsigned int uint
unsigned int uint32
Definition: OgrePlatform.h:359
_StringBase String
std::map< K, V, P, A > type

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.