OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::CompositorWorkspace Class Reference

A compositor workspace is the main interface to render into an RT, be it a RenderWindow or an RTT (Render Texture Target). More...

#include <OgreCompositorWorkspace.h>

+ Inheritance diagram for Ogre::CompositorWorkspace:
+ Collaboration diagram for Ogre::CompositorWorkspace:

Public Member Functions

 CompositorWorkspace (IdType id, const CompositorWorkspaceDef *definition, const CompositorChannel &finalRenderTarget, SceneManager *sceneManager, Camera *defaultCam, RenderSystem *renderSys, bool bEnabled)
 
virtual ~CompositorWorkspace ()
 
void _beginUpdate (bool forceBeginFrame)
 Call before _update unless the final render target is not a render window. More...
 
void _endUpdate (bool forceEndFrame)
 Call after _update unless the final render target is not a render window. More...
 
void _swapFinalTarget (void)
 In the case of RenderWindows, swaps/copies/flips the front with the back buffer. More...
 
void _update (void)
 Updates the workspace's nodes. More...
 
void _validateFinalTarget (void)
 For compatibility with D3D9, forces a device lost check on the RenderWindow, so that BeginScene doesn't fail. More...
 
CamerafindCamera (IdString cameraName) const
 Finds a camera in the scene manager we have. More...
 
CompositorNodefindNode (IdString aliasName, bool includeShadowNodes=false) const
 Finds a node instance with the given aliased name. More...
 
CompositorShadowNodefindOrCreateShadowNode (IdString nodeDefName, bool &bCreated)
 Finds a shadow node given it's definition name. More...
 
CompositorShadowNodefindShadowNode (IdString nodeDefName) const
 Finds a shadow node instance with a given name. More...
 
CompositorManager2getCompositorManager ()
 Gets the compositor manager (non const) More...
 
const CompositorManager2getCompositorManager () const
 Gets the compositor manager (const version) More...
 
CameragetDefaultCamera () const
 Gets the default camera passed through mDefaultViewport. More...
 
bool getEnabled () const
 
size_t getFrameCount (void) const
 
const CompositorChannelgetGlobalTexture (IdString name) const
 
IdType getId () const
 Get the unique id of this object. More...
 
CompositorWorkspaceListenergetListener (void) const
 
const CompositorNodeVecgetNodeSequence (void) const
 
SceneManagergetSceneManager () const
 
bool isValid (void) const
 Only valid workspaces can update without crashing. 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)
 
bool operator() (const IdObject *left, const IdObject *right)
 
bool operator() (const IdObject &left, const IdObject &right)
 
void reconnectAllNodes (void)
 Reconnects all nodes. More...
 
void recreateAllNodes (void)
 Destroys and recreates all nodes. More...
 
void setEnabled (bool bEnabled)
 
void setListener (CompositorWorkspaceListener *listener)
 

Protected Member Functions

void _setId (IdType newId)
 In the rare case our derived class wants to override our Id (normally we don't want that, that's why it's private). More...
 
void clearAllConnections (void)
 
void connectAllNodes (void)
 Connects all nodes' input and output channels (including final rt) according to our definition. More...
 
void createAllNodes (void)
 Creates all the node instances from our definition. More...
 
void destroyAllNodes (void)
 Destroys all node instances. More...
 
void setupPassesShadowNodes (void)
 Setup ShadowNodes in every pass from every node so that we recalculate them as little as possible (when passes use SHADOW_NODE_FIRST_ONLY flag) More...
 

Protected Attributes

uint mCurrentHeight
 
uint mCurrentWidth
 
CameramDefaultCamera
 
CompositorWorkspaceDef const * mDefinition
 
bool mEnabled
 
CompositorChannelVec mGlobalTextures
 
CompositorWorkspaceListenermListener
 
CompositorNodeVec mNodeSequence
 Main sequence in the order they should be executed. More...
 
RenderSystemmRenderSys
 
CompositorChannel mRenderWindow
 
SceneManagermSceneManager
 Could be null. CompositorManager2::addWorkspace. More...
 
CompositorShadowNodeVec mShadowNodes
 
bool mValid
 

Detailed Description

A compositor workspace is the main interface to render into an RT, be it a RenderWindow or an RTT (Render Texture Target).

Whereas Ogre 1.x needed you to set a Viewport in order to render to an RTT or RW and then call renderTarget->update, now you need to set a workspace definition instead and call workspace->_update().

Compositors are not just a "fancy effects" system anymore, they tell Ogre how you want to render the scene. You can't render to an RT without setting a compositor!
A workspace may be instantiated multiple times for different RTs, or using different cameras (i.e. multiple monitors, stereo 3D, etc), while they all will share the same definition. A workspace definition (
See also
CompositorWorkspaceDef) contains all the information needed by this CompositorWorkspace to instantiate and know which nodes to create and how to connect them. CompositorNodeDef A workspace may define global textures that are visible to all of its Node instances.
If you want to have (e.g.) two monitors rendering the same but with different compositor effects, you will also have to create two different definitions (CompositorWorkspaceDefs)
The intention of Ogre 2.0's compositor is to ideally have one Workspace per monitor (or per eye) while handling all RTTs inside that workspace with compositor nodes, local and global textures (including manually updated stuff like procedural textures, terrain's auto generated normal maps, etc); but it is also possible to do things the 1.x way: use additional Workspaces for manually rendering and controlling RTTs.
Users with basic needs (no advanced effects) can
See also
CompositorManager2::createBasicWorkspaceDef for quickly having a basic definition set for them.
For more information about Compositors, consult the Ogre 2.0 Porting Manual in the Docs folder.
Author
Matias N. Goldberg
Version
1.1

Definition at line 78 of file OgreCompositorWorkspace.h.

Constructor & Destructor Documentation

Ogre::CompositorWorkspace::CompositorWorkspace ( IdType  id,
const CompositorWorkspaceDef definition,
const CompositorChannel finalRenderTarget,
SceneManager sceneManager,
Camera defaultCam,
RenderSystem renderSys,
bool  bEnabled 
)
virtual Ogre::CompositorWorkspace::~CompositorWorkspace ( )
virtual

Member Function Documentation

void Ogre::CompositorWorkspace::_beginUpdate ( bool  forceBeginFrame)

Call before _update unless the final render target is not a render window.

Parameters
forceBeginFrameForces a beginFrame call to the D3D9 API, even if the final render target is not a RenderWindow (not recommended). To avoid forcing extra begin/end frame pairs, update your manual workspaces inside ::workspacePreUpdate (performance optimization)
void Ogre::CompositorWorkspace::_endUpdate ( bool  forceEndFrame)

Call after _update unless the final render target is not a render window.

Parameters
forceEndFrame_beginUpdate !!!WARNING!!! Forcing an end frame can cause API issues w/ D3D9 if Ogre had already issued a begin frame automatically (i.e. if you're calling from inside a RenderTarget or CompositorWorkspace listener). These API issues may not manifest on all HW/Driver combinations, making it hard to detect (if you're on D3D, use the Debug Runtimes)
void Ogre::IdObject::_setId ( IdType  newId)
inlineprotectedinherited

In the rare case our derived class wants to override our Id (normally we don't want that, that's why it's private).

Definition at line 63 of file OgreId.h.

void Ogre::CompositorWorkspace::_swapFinalTarget ( void  )

In the case of RenderWindows, swaps/copies/flips the front with the back buffer.

In the case of RenderTextures, resolves FSAA (unless it's tagged as explicit resolve, or its contents haven't changed since the last resolve)

Remarks
Call this after _endUpdate
void Ogre::CompositorWorkspace::_update ( void  )

Updates the workspace's nodes.

void Ogre::CompositorWorkspace::_validateFinalTarget ( void  )

For compatibility with D3D9, forces a device lost check on the RenderWindow, so that BeginScene doesn't fail.

void Ogre::CompositorWorkspace::clearAllConnections ( void  )
protected
void Ogre::CompositorWorkspace::connectAllNodes ( void  )
protected

Connects all nodes' input and output channels (including final rt) according to our definition.

Then creates the passes from all nodes

Remarks
Call this function after createAllNodes
Parameters
reconnectWhen true, assumes the node's passes have already been created and we're just connecting the channels again.
void Ogre::CompositorWorkspace::createAllNodes ( void  )
protected

Creates all the node instances from our definition.

void Ogre::CompositorWorkspace::destroyAllNodes ( void  )
protected

Destroys all node instances.

Camera* Ogre::CompositorWorkspace::findCamera ( IdString  cameraName) const

Finds a camera in the scene manager we have.

CompositorNode* Ogre::CompositorWorkspace::findNode ( IdString  aliasName,
bool  includeShadowNodes = false 
) const

Finds a node instance with the given aliased name.

Remarks
Linear search O(N)
Parameters
aliasNameName of the node instance (they're unique)
includeShadowNodesWhen true, also looks for ShadowNodes with that name, if the instance doesn't exists, it will not be created (default: false). findShadowNode When a Node has the same name of a Shadow Node, the Node takes precedence.
Returns
Null if not found. Valid pointer otherwise.
CompositorShadowNode* Ogre::CompositorWorkspace::findOrCreateShadowNode ( IdString  nodeDefName,
bool &  bCreated 
)

Finds a shadow node given it's definition name.

If it doesn't exist, creates one. Note that unlike nodes, there can only be one ShadowNode instance per definition (in the same workspace)

Remarks
Performs a linear search O(N). There aren't many ShadowNodes active in a workspace to justify a better container (plus we mostly iterate through it).
Throws if the shadow definition doesn't exist.
Parameters
nodeDefNameName of the definition.
bCreated[out] Set to true if we had to create a new shadow node (it didn't exist)
Returns
ShadowNode pointer
CompositorShadowNode* Ogre::CompositorWorkspace::findShadowNode ( IdString  nodeDefName) const

Finds a shadow node instance with a given name.

Note that unlike nodes, there can only be one ShadowNode instance per definition (in the same workspace)

Remarks
Performs a linear search O(N). There aren't many ShadowNodes active in a workspace to justify a better container (plus we mostly iterate through it).
Parameters
nodeDefNameName of the definition.
Returns
ShadowNode pointer. Null if not found.
CompositorManager2* Ogre::CompositorWorkspace::getCompositorManager ( )

Gets the compositor manager (non const)

const CompositorManager2* Ogre::CompositorWorkspace::getCompositorManager ( ) const

Gets the compositor manager (const version)

Camera* Ogre::CompositorWorkspace::getDefaultCamera ( ) const
inline

Gets the default camera passed through mDefaultViewport.

Definition at line 242 of file OgreCompositorWorkspace.h.

bool Ogre::CompositorWorkspace::getEnabled ( ) const
inline

Definition at line 138 of file OgreCompositorWorkspace.h.

size_t Ogre::CompositorWorkspace::getFrameCount ( void  ) const
const CompositorChannel& Ogre::CompositorWorkspace::getGlobalTexture ( IdString  name) const
IdType Ogre::IdObject::getId ( ) const
inlineinherited

Get the unique id of this object.

Definition at line 74 of file OgreId.h.

CompositorWorkspaceListener* Ogre::CompositorWorkspace::getListener ( void  ) const
inline

Definition at line 141 of file OgreCompositorWorkspace.h.

const CompositorNodeVec& Ogre::CompositorWorkspace::getNodeSequence ( void  ) const
inline

Definition at line 236 of file OgreCompositorWorkspace.h.

SceneManager* Ogre::CompositorWorkspace::getSceneManager ( ) const
inline

Definition at line 244 of file OgreCompositorWorkspace.h.

bool Ogre::CompositorWorkspace::isValid ( void  ) const
inline

Only valid workspaces can update without crashing.

Definition at line 135 of file OgreCompositorWorkspace.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

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

Definition at line 108 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

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

Definition at line 119 of file OgreMemoryAllocatedObject.h.

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

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

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

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

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

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

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

Definition at line 91 of file OgreMemoryAllocatedObject.h.

bool Ogre::IdObject::operator() ( const IdObject left,
const IdObject right 
)
inlineinherited

Definition at line 76 of file OgreId.h.

References Ogre::IdObject::mId.

bool Ogre::IdObject::operator() ( const IdObject left,
const IdObject right 
)
inlineinherited

Definition at line 81 of file OgreId.h.

References Ogre::IdObject::mId.

void Ogre::CompositorWorkspace::reconnectAllNodes ( void  )

Reconnects all nodes.

Use this function if you only altered the channel connections between nodes, but didn't add new ones or removed existing nodes.

Remarks
If there is a "loose node" (its inputs are not fully connected), disable it (
See also
CompositorNode::setEnabled)
void Ogre::CompositorWorkspace::recreateAllNodes ( void  )

Destroys and recreates all nodes.

TODO: Only revalidate nodes adjacent to those that were invalidated, to avoid recreating so many D3D/GL resources (local textures) which is important for GUI editors.

void Ogre::CompositorWorkspace::setEnabled ( bool  bEnabled)
inline

Definition at line 137 of file OgreCompositorWorkspace.h.

void Ogre::CompositorWorkspace::setListener ( CompositorWorkspaceListener listener)
inline

Definition at line 140 of file OgreCompositorWorkspace.h.

void Ogre::CompositorWorkspace::setupPassesShadowNodes ( void  )
protected

Setup ShadowNodes in every pass from every node so that we recalculate them as little as possible (when passes use SHADOW_NODE_FIRST_ONLY flag)

Remarks
Call this function after calling createPasses() on every node, since we need the passes to have been already created

Member Data Documentation

uint Ogre::CompositorWorkspace::mCurrentHeight
protected

Definition at line 98 of file OgreCompositorWorkspace.h.

uint Ogre::CompositorWorkspace::mCurrentWidth
protected

Definition at line 97 of file OgreCompositorWorkspace.h.

Camera* Ogre::CompositorWorkspace::mDefaultCamera
protected

Definition at line 92 of file OgreCompositorWorkspace.h.

CompositorWorkspaceDef const* Ogre::CompositorWorkspace::mDefinition
protected

Definition at line 81 of file OgreCompositorWorkspace.h.

bool Ogre::CompositorWorkspace::mEnabled
protected

Definition at line 84 of file OgreCompositorWorkspace.h.

CompositorChannelVec Ogre::CompositorWorkspace::mGlobalTextures
protected

Definition at line 91 of file OgreCompositorWorkspace.h.

CompositorWorkspaceListener* Ogre::CompositorWorkspace::mListener
protected

Definition at line 86 of file OgreCompositorWorkspace.h.

CompositorNodeVec Ogre::CompositorWorkspace::mNodeSequence
protected

Main sequence in the order they should be executed.

Definition at line 89 of file OgreCompositorWorkspace.h.

RenderSystem* Ogre::CompositorWorkspace::mRenderSys
protected

Definition at line 94 of file OgreCompositorWorkspace.h.

CompositorChannel Ogre::CompositorWorkspace::mRenderWindow
protected

Definition at line 96 of file OgreCompositorWorkspace.h.

SceneManager* Ogre::CompositorWorkspace::mSceneManager
protected

Could be null. CompositorManager2::addWorkspace.

Definition at line 93 of file OgreCompositorWorkspace.h.

CompositorShadowNodeVec Ogre::CompositorWorkspace::mShadowNodes
protected

Definition at line 90 of file OgreCompositorWorkspace.h.

bool Ogre::CompositorWorkspace::mValid
protected

Definition at line 83 of file OgreCompositorWorkspace.h.


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