Ogre::CompositorInstance Class Reference
Core » Effects

An instance of a Compositor object for one Viewport. More...

`#include <OgreCompositorInstance.h>`

Inheritance diagram for Ogre::CompositorInstance:
[legend]

## Classes

class | Listener
| Provides an interface to "listen in" to to render system operations executed by this CompositorInstance. More...
class | RenderSystemOperation
| Specific render system operation. More...
class | TargetOperation
| Operation setup for a RenderTarget (collected). More...

## Public Types

typedef vector< TargetOperation >::type | CompiledState
typedef map< int, MaterialPtr >::type | QuadMaterialMap
typedef std::pair< int, RenderSystemOperation * > | RenderSystemOpPair
typedef vector< RenderSystemOpPair >::type | RenderSystemOpPairs

## Public Member Functions

| CompositorInstance (CompositionTechnique *technique, CompositorChain *chain)
virtual | ~CompositorInstance ()
virtual void | _compileOutputOperation (TargetOperation &finalState)
| Compile the final (output) operation. More...
virtual void | _compileTargetOperations (CompiledState &compiledState)
| Recursively collect target states (except for final Pass). More...
void | _fireNotifyMaterialRender (uint32 pass_id, MaterialPtr &mat)
| Notify listeners of a material render. More...
void | _fireNotifyMaterialSetup (uint32 pass_id, MaterialPtr &mat)
| Notify listeners of a material compilation. More...
void | _fireNotifyResourcesCreated (bool forResizeOnly)
| Notify listeners of a material render. More...
void | addListener (Listener *l)
| Add a listener. More...
bool | getAlive () const
| Get alive flag. More...
CompositorChain * | getChain ()
| Get Chain that this instance is part of. More...
Compositor * | getCompositor ()
| Get Compositor of which this is an instance. More...
bool | getEnabled () const
| Get enabled flag. More...
RenderTarget * | getRenderTarget (const String &name)
| Get the render target for a given render texture name. More...
const String & | getScheme () const
| Returns the name of the scheme this compositor is using. More...
CompositionTechnique * | getTechnique ()
| Get CompositionTechnique used by this instance. More...
TexturePtr | getTextureInstance (const String &name, size_t mrtIndex)
| Get the instance of a local texture. More...
const String & | getTextureInstanceName (const String &name, size_t mrtIndex)
| Get the instance name for a local texture. More...
void | notifyResized ()
| Notify this instance that the primary surface has been resized. More...
void | operator delete (void *ptr)
void | operator delete (void *ptr, void *)
void | operator delete (void *ptr, const char *, int, const char *)
void | operator delete[] (void *ptr)
void | operator delete[] (void *ptr, const char *, int, const char *)
void * | operator new (size_t sz, const char *file, int line, const char *func)
| operator new, with debug line info More...
void * | operator new (size_t sz)
void * | operator new (size_t sz, void *ptr)
| placement operator new More...
void * | operator new[] (size_t sz, const char *file, int line, const char *func)
| array operator new, with debug line info More...
void * | operator new[] (size_t sz)
void | removeListener (Listener *l)
| Remove a listener. More...
void | setAlive (bool value)
| Set alive/active flag. More...
void | setEnabled (bool value)
| Set enabled flag. More...
void | setScheme (const String &schemeName, bool reuseTextures=true)
| Pick a technique to use to render this compositor based on a scheme. More...
void | setTechnique (CompositionTechnique *tech, bool reuseTextures=true)
| Change the technique we're using to render this compositor. More...

## Private Types

typedef vector< Listener * >::type | Listeners
| Vector of listeners. More...
typedef map< String, MultiRenderTarget * >::type | LocalMRTMap
| Store a list of MRTs we've created. More...
typedef map< String, TexturePtr >::type | LocalTextureMap
| Map from name->local texture. More...
typedef map< CompositionTechnique::TextureDefinition *, TexturePtr >::type | ReserveTextureMap

## Private Member Functions

virtual void | collectPasses (TargetOperation &finalState, CompositionTargetPass *target)
| Collect rendering passes. More...
MaterialPtr | createLocalMaterial (const String &srcName)
| Create a local dummy material with one technique but no passes. More...
void | createResources (bool forResizeOnly)
| Create local rendertextures and other resources. More...
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 target to which we're attached. More...
void | freeResources (bool forResizeOnly, bool clearReserveTextures)
| Destroy local rendertextures and other resources. More...
String | getMRTTexLocalName (const String &baseName, size_t attachment)
| Util method for assigning a local texture name to a MRT attachment. More...
const String & | getSourceForTex (const String &name, size_t mrtIndex=0)
| Get source texture name for a named local texture. More...
RenderTarget * | getTargetForTex (const String &name)
| Get RenderTarget for a named local texture. More...
void | notifyCameraChanged (Camera *camera)
| Notify this instance that the primary viewport's camera has changed. More...
void | queueRenderSystemOp (TargetOperation &finalState, RenderSystemOperation *op)
| Queue a render system operation. More...

## Private Attributes

bool | mAlive
| Is this instance allocating resources? More...
CompositorChain * | mChain
| Composition chain of which this instance is part. More...
Compositor * | mCompositor
| Compositor of which this is an instance. More...
bool | mEnabled
| Is this instance enabled? More...
Listeners | mListeners
LocalMRTMap | mLocalMRTs
LocalTextureMap | mLocalTextures
CompositorInstance * | mPreviousInstance
| Previous instance (set by chain). More...
ReserveTextureMap | mReserveTextures
| Textures that are not currently in use, but that we want to keep for now, for example if we switch techniques but want to keep all textures available in case we switch back. More...
CompositionTechnique * | mTechnique
| Composition technique used by this instance. More...

## Friends

class | CompositorChain

## Detailed Description

An instance of a Compositor object for one Viewport.

It is part of the CompositorChain for a Viewport.

Definition at line 50 of file OgreCompositorInstance.h.

## Member Typedef Documentation

## CompiledState

typedef vector<TargetOperation>::type Ogre::CompositorInstance::CompiledState

Definition at line 164 of file OgreCompositorInstance.h.

## Listeners

typedef vector<Listener*>::type Ogre::CompositorInstance::Listeners

private

Vector of listeners.

Definition at line 332 of file OgreCompositorInstance.h.

## LocalMRTMap

typedef map<String,MultiRenderTarget*>::type Ogre::CompositorInstance::LocalMRTMap

private

Store a list of MRTs we've created.

Definition at line 322 of file OgreCompositorInstance.h.

## LocalTextureMap

typedef map<String,TexturePtr>::type Ogre::CompositorInstance::LocalTextureMap

private

Map from name->local texture.

Definition at line 319 of file OgreCompositorInstance.h.

## QuadMaterialMap

typedef map<int, MaterialPtr>::type Ogre::CompositorInstance::QuadMaterialMap

Definition at line 106 of file OgreCompositorInstance.h.

## RenderSystemOpPair

typedef std::pair<int, RenderSystemOperation*> Ogre::CompositorInstance::RenderSystemOpPair

Definition at line 107 of file OgreCompositorInstance.h.

## RenderSystemOpPairs

typedef vector<RenderSystemOpPair>::type Ogre::CompositorInstance::RenderSystemOpPairs

Definition at line 108 of file OgreCompositorInstance.h.

## ReserveTextureMap

typedef map<CompositionTechnique::TextureDefinition*, TexturePtr>::type Ogre::CompositorInstance::ReserveTextureMap

private

Definition at line 324 of file OgreCompositorInstance.h.

## Constructor & Destructor Documentation

## CompositorInstance()

Ogre::CompositorInstance::CompositorInstance | ( | CompositionTechnique * | technique,
|  | CompositorChain * | chain
| ) |  |

## ~CompositorInstance()

virtual Ogre::CompositorInstance::~CompositorInstance | ( |  | ) |

virtual

## Member Function Documentation

## _compileOutputOperation()

virtual void Ogre::CompositorInstance::_compileOutputOperation | ( | TargetOperation & | finalState | ) |

virtual

Compile the final (output) operation.

This is done separately because this is combined with the input in chained filters.

## _compileTargetOperations()

virtual void Ogre::CompositorInstance::_compileTargetOperations | ( | CompiledState & | compiledState | ) |

virtual

Recursively collect target states (except for final Pass).

Parameters

  compiledState | This vector will contain a list of TargetOperation objects.

## _fireNotifyMaterialRender()

void Ogre::CompositorInstance::_fireNotifyMaterialRender | ( | uint32 | pass_id,
|  | MaterialPtr & | mat
| ) |  |

Notify listeners of a material render.

## _fireNotifyMaterialSetup()

void Ogre::CompositorInstance::_fireNotifyMaterialSetup | ( | uint32 | pass_id,
|  | MaterialPtr & | mat
| ) |  |

Notify listeners of a material compilation.

## _fireNotifyResourcesCreated()

void Ogre::CompositorInstance::_fireNotifyResourcesCreated | ( | bool | forResizeOnly | ) |

Notify listeners of a material render.

## addListener()

void Ogre::CompositorInstance::addListener | ( | Listener * | l | ) |

Add a listener.

Listeners provide an interface to "listen in" to to render system operations executed by this CompositorInstance so that materials can be programmatically set up.

See also
  CompositorInstance::Listener

## collectPasses()

virtual void Ogre::CompositorInstance::collectPasses | ( | TargetOperation & | finalState,
|  | CompositionTargetPass * | target
| ) |  |

private virtual

Collect rendering passes.

Here, passes are converted into render target operations and queued with queueRenderSystemOp.

## createLocalMaterial()

MaterialPtr Ogre::CompositorInstance::createLocalMaterial | ( | const String & | srcName | ) |

private

Create a local dummy material with one technique but no passes.

The material is detached from the Material Manager to make sure it is destroyed when going out of scope.

## createResources()

void Ogre::CompositorInstance::createResources | ( | bool | forResizeOnly | ) |

private

Create local rendertextures and other resources.

Builds mLocalTextures.

## deriveTextureRenderTargetOptions()

void Ogre::CompositorInstance::deriveTextureRenderTargetOptions | ( | const String & | texname,
|  | bool * | hwGammaWrite,
|  | uint * | fsaa,
|  | String * | fsaaHint
| ) |  |

private

Search for options like AA and hardware gamma which we may want to inherit from the main render target to which we're attached.

## freeResources()

void Ogre::CompositorInstance::freeResources | ( | bool | forResizeOnly,
|  | bool | clearReserveTextures
| ) |  |

private

Destroy local rendertextures and other resources.

## getAlive()

bool Ogre::CompositorInstance::getAlive | ( |  | ) | const

Get alive flag.

Definition at line 186 of file OgreCompositorInstance.h.

## getChain()

CompositorChain* Ogre::CompositorInstance::getChain | ( |  | ) |

Get Chain that this instance is part of.

## getCompositor()

Compositor* Ogre::CompositorInstance::getCompositor | ( |  | ) |

Get Compositor of which this is an instance.

## getEnabled()

bool Ogre::CompositorInstance::getEnabled | ( |  | ) | const

Get enabled flag.

Definition at line 174 of file OgreCompositorInstance.h.

## getMRTTexLocalName()

String Ogre::CompositorInstance::getMRTTexLocalName | ( | const String & | baseName,
|  | size_t | attachment
| ) |  |

private

Util method for assigning a local texture name to a MRT attachment.

## getRenderTarget()

RenderTarget* Ogre::CompositorInstance::getRenderTarget | ( | const String & | name | ) |

Get the render target for a given render texture name.

Remarks
  You can use this to add listeners etc, but do not use it to update the targets manually or any other modifications, the compositor instance is in charge of this.

## getScheme()

const String& Ogre::CompositorInstance::getScheme | ( |  | ) | const

Returns the name of the scheme this compositor is using.

Definition at line 271 of file OgreCompositorInstance.h.

References Ogre::StringUtil::BLANK.

## getSourceForTex()

const String& Ogre::CompositorInstance::getSourceForTex | ( | const String & | name,
|  | size_t | mrtIndex = `0`
| ) |  |

private

Get source texture name for a named local texture.

Parameters

  name | The local name of the texture as given to it in the compositor.
  mrtIndex | For MRTs, which attached surface to retrieve.

## getTargetForTex()

RenderTarget* Ogre::CompositorInstance::getTargetForTex | ( | const String & | name | ) |

private

Get RenderTarget for a named local texture.

## getTechnique()

CompositionTechnique* Ogre::CompositorInstance::getTechnique | ( |  | ) |

Get CompositionTechnique used by this instance.

## getTextureInstance()

TexturePtr Ogre::CompositorInstance::getTextureInstance | ( | const String & | name,
|  | size_t | mrtIndex
| ) |  |

Get the instance of a local texture.

Note
  Textures are only valid when local textures have been loaded, which in practice means that the compositor instance is active. Calling this method at other times will return null pointers. Note that since textures are cleaned up aggressively, this pointer is not guaranteed to stay the same if you disable and re-enable the compositor instance.

Parameters

  name | The name of the texture in the original compositor definition.
  mrtIndex | If name identifies a MRT, which texture attachment to retrieve.

Returns
  The texture pointer, corresponds to a real texture.

## getTextureInstanceName()

const String& Ogre::CompositorInstance::getTextureInstanceName | ( | const String & | name,
|  | size_t | mrtIndex
| ) |  |

Get the instance name for a local texture.

Note
  It is only valid to call this when local textures have been loaded, which in practice means that the compositor instance is active. Calling it at other times will cause an exception. Note that since textures are cleaned up aggressively, this name is not guaranteed to stay the same if you disable and re-enable the compositor instance.

Parameters

  name | The name of the texture in the original compositor definition.
  mrtIndex | If name identifies a MRT, which texture attachment to retrieve.

Returns
  The instance name for the texture, corresponds to a real texture.

## notifyCameraChanged()

void Ogre::CompositorInstance::notifyCameraChanged | ( | Camera * | camera | ) |

private

Notify this instance that the primary viewport's camera has changed.

## notifyResized()

void Ogre::CompositorInstance::notifyResized | ( |  | ) |

Notify this instance that the primary surface has been resized.

Remarks
  This will allow the instance to recreate its resources that are dependent on the size.

## operator delete() [1/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) |

inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

## operator delete() [2/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  |

inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

## operator delete() [3/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [1/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) |

inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [2/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

## operator new() [1/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

## operator new() [2/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) |

inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

## operator new() [3/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | void * | ptr
| ) |  |

inherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

## operator new[]() [1/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

## operator new[]() [2/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) |

inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

## queueRenderSystemOp()

void Ogre::CompositorInstance::queueRenderSystemOp | ( | TargetOperation & | finalState,
|  | RenderSystemOperation * | op
| ) |  |

private

Queue a render system operation.

## removeListener()

void Ogre::CompositorInstance::removeListener | ( | Listener * | l | ) |

Remove a listener.

See also
  CompositorInstance::Listener

## setAlive()

void Ogre::CompositorInstance::setAlive | ( | bool | value | ) |

Set alive/active flag.

The compositor instance will create resources when alive, and destroy them when inactive.

Remarks
  Killing an instance means also disabling it: setAlive(false) implies setEnabled(false)

## setEnabled()

void Ogre::CompositorInstance::setEnabled | ( | bool | value | ) |

Set enabled flag.

The compositor instance will only render if it is enabled, otherwise it is pass-through. Resources are only created if they weren't alive when enabling.

## setScheme()

void Ogre::CompositorInstance::setScheme | ( | const String & | schemeName,
|  | bool | reuseTextures = `true`
| ) |  |

Pick a technique to use to render this compositor based on a scheme.

Remarks
  If there is no specific supported technique with this scheme name, then the first supported technique with no specific scheme will be used.

See also
  CompositionTechnique::setSchemeName

Parameters

  schemeName | The scheme to use
  reuseTextures | If textures have already been created for the current technique, whether to try to re-use them if sizes & formats match. Note that for this feature to be of benefit, the textures must have been created with the 'pooled' option enabled.

## setTechnique()

void Ogre::CompositorInstance::setTechnique | ( | CompositionTechnique * | tech,
|  | bool | reuseTextures = `true`
| ) |  |

Change the technique we're using to render this compositor.

Parameters

  tech | The technique to use (must be supported and from the same Compositor)
  reuseTextures | If textures have already been created for the current technique, whether to try to re-use them if sizes & formats match.

## Friends And Related Function Documentation

## CompositorChain

friend class CompositorChain

friend

Definition at line 385 of file OgreCompositorInstance.h.

## Member Data Documentation

## mAlive

bool Ogre::CompositorInstance::mAlive

private

Is this instance allocating resources?

Definition at line 317 of file OgreCompositorInstance.h.

## mChain

CompositorChain* Ogre::CompositorInstance::mChain

private

Composition chain of which this instance is part.

Definition at line 313 of file OgreCompositorInstance.h.

## mCompositor

Compositor* Ogre::CompositorInstance::mCompositor

private

Compositor of which this is an instance.

Definition at line 309 of file OgreCompositorInstance.h.

## mEnabled

bool Ogre::CompositorInstance::mEnabled

private

Is this instance enabled?

Definition at line 315 of file OgreCompositorInstance.h.

## mListeners

Listeners Ogre::CompositorInstance::mListeners

private

Definition at line 333 of file OgreCompositorInstance.h.

## mLocalMRTs

LocalMRTMap Ogre::CompositorInstance::mLocalMRTs

private

Definition at line 323 of file OgreCompositorInstance.h.

## mLocalTextures

LocalTextureMap Ogre::CompositorInstance::mLocalTextures

private

Definition at line 320 of file OgreCompositorInstance.h.

## mPreviousInstance

CompositorInstance* Ogre::CompositorInstance::mPreviousInstance

private

Previous instance (set by chain).

Definition at line 336 of file OgreCompositorInstance.h.

## mReserveTextures

ReserveTextureMap Ogre::CompositorInstance::mReserveTextures

private

Textures that are not currently in use, but that we want to keep for now, for example if we switch techniques but want to keep all textures available in case we switch back.

Definition at line 329 of file OgreCompositorInstance.h.

## mTechnique

CompositionTechnique* Ogre::CompositorInstance::mTechnique

private

Composition technique used by this instance.

Definition at line 311 of file OgreCompositorInstance.h.

The documentation for this class was generated from the following file:

- OgreCompositorInstance.h

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