Tuesday, March 10, 2009

Details of how compositor works

The compositor framework hooked into the Ogre rendering pipeline by setting up a RenderTargetListener(CompositorChain).
It is setup when the client call CompositorManager::addCompositor() -> CompositorChain::addCompositor() -> "mViewport->getTarget()->addListener(this);".
It is responsible for registering another listener: RenderQueueListener(CompositorChain::RQListener).

When the "renderQueueStarted" event of RenderQueueListener is fired, it executes all the render operations inside that CompositorChain.
Render operations are represented by the class "CompositorInstance::TargetOperation".
It is the abstract class. The real render operations("clear", "stencil", "quad") are based on it.

The real rendering is executed immediately when CompositorInstance::TargetOperation::execute() is called. For example, in "quad" operation, it sets up the camera, viewport, the full screen quad object, and inject it into the SceneManager and render it.

In the compositor framework, CompositorInstance is just a render operations container, which enqueues the render operations into the CompositorChain. The CompositorChain is the real important class.

No comments: