Cerberus X Documentation

Class Renderer

A renderer is used to draw complex scenes using multipass rendering. More...

Declarations

Properties
Layers : Stack<ILayer> () Get layer stack.
Constructors
New () Create a new renderer.
Methods
Render : Void () Render everything.
SetAmbientLight : Void ( ambientLight:Float[] ) Set ambient light.
SetCameraMatrix : Void ( cameraMatrix:Float[] ) Set 4x4 camera matrix.
SetClearColor : Void ( clearColor:Float[] ) Set clear color.
SetClearMode : Void ( clearMode:Int ) Set clear mode.
SetProjectionMatrix : Void ( projectionMatrix:Float[] ) Set 4x4 projection matrix.
SetRenderTarget : Void ( image:Image ) Change render target.
SetViewport : Void ( x:Int, y:Int, width:Int, height:Int ) Set viewport.

Detailed Discussion

A renderer is used to draw complex scenes using multipass rendering.

To do this, renderer uses the idea of layers to manage the drawing of 2d primitives. Layers are added to a renderer by pushing them onto a renderer's layer stack and, when it is time to render, the renderer calls the ILayer.OnRenderLayer method to cause each layer to render itself. Layers are rendered in the order they are pushed on the layer stack.

To use renderer, you must write classes that implement the ILight and ILayer interfaces. You add layer objects to a renderer by pushing them on the renderer's Layers stack before rendering. You add lights when the renderer calls the ILayer.EnumLayerLights method during rendering.

Renderer also handles shadow rendering. To add shadow casters to a scene, you can either call the DrawList.AddShadowCaster method while rendering a layer inside ILayer.OnRenderLayer, or you can simply draw images with shadow casters attached via Image.SetShadowCaster.


Properties Documentation

Method Layers : Stack<ILayer> () Property

Get layer stack.


Constructors Documentation

Method New ()

Create a new renderer.

By default, a renderer will render to the back buffer. To change this, use SetRenderTarget.


Methods Documentation

Method Render : Void ()

Render everything.

Method SetAmbientLight : Void ( ambientLight:Float[] )

Set ambient light.

Method SetCameraMatrix : Void ( cameraMatrix:Float[] )

Set 4x4 camera matrix.

Method SetClearColor : Void ( clearColor:Float[] )

Set clear color.

Method SetClearMode : Void ( clearMode:Int )

Set clear mode.

ModeEffect
0Canvas is not cleared by renderer.
1Canvas is cleared using clear color.
Method SetProjectionMatrix : Void ( projectionMatrix:Float[] )

Set 4x4 projection matrix.

Method SetRenderTarget : Void ( image:Image )

Change render target.

Method SetViewport : Void ( x:Int, y:Int, width:Int, height:Int )

Set viewport.