Loading [MathJax]/extensions/tex2jax.js
Carna  Version 3.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Public Member Functions | List of all members
Carna::base::FrameRenderer Class Reference

Defines logic for rendering frames from given scenes. More...

#include <FrameRenderer.h>

+ Inheritance diagram for Carna::base::FrameRenderer:
+ Collaboration diagram for Carna::base::FrameRenderer:

Classes

struct  RenderTextureParams
 Specifies how renderTexture is to be performed. More...
 

Public Member Functions

 FrameRenderer (GLContext &glContext, unsigned int width, unsigned int height, bool fitSquare)
 Instantiates with empty rendering stages sequence. More...
 
virtual ~FrameRenderer ()
 Deletes all stages contained by this renderer.
 
GLContextglContext () const
 Represents the OpenGL context that this renderer is associated with.
 
virtual void clearStages () override
 Activates glContext and deletes all stages from the rendering stages sequence.
 
unsigned int width () const
 Tells the current frame width. Value is changed through reshape.
 
unsigned int height () const
 Tells the current frame height. Value is changed through reshape.
 
const Viewportviewport () const
 Tells the root viewport that frames are currently rendered with. Value is changed through reshape.
 
void setBackgroundColor (const math::Vector4f &)
 Sets frame background color. Default value is Color::BLACK_NO_ALPHA.
 
void reshape (unsigned int width, unsigned int height, bool fitSquare)
 Sets width, height and root viewport of future rendered frames. More...
 
void reshape (unsigned int width, unsigned int height)
 
void render (Camera &cam, Node &root) const
 Renders scene root from cam point of view to the currently bound framebuffer by issuing the rendering process. The scene graph concept is explained here.
 
void render (Camera &cam) const
 
void renderTexture (const RenderTextureParams &params) const
 Renders rectangle that covers the current viewport, according to params. Refer to RenderTextureParams for further notes. More...
 
const math::Statistics< double > & framesPerSecond () const
 Tells the average of the reciprocal frame rendering time.
 
- Public Member Functions inherited from Carna::base::RenderStageSequence
 RenderStageSequence ()
 Instantiates.
 
virtual ~RenderStageSequence ()
 Deletes all stages contained by the sequence.
 
std::size_t stages () const
 Tells number of stages contained by the sequence.
 
void appendStage (RenderStage *stage)
 Appends stage to the rendering stages sequence.
 
RenderStagestageAt (std::size_t position) const
 References the stage at position within the rendering stages sequence.
 
template<typename RenderStage >
Aggregation< RenderStagefindStage () const
 References the first RenderStage within the rendering stages sequence. This method performs a linear search. Returns Aggregation::NULL_PTR if RenderStage is not found withing hte rendering stages sequence.
 

Additional Inherited Members

- Protected Member Functions inherited from Carna::base::RenderStageSequence
void releaseStages ()
 Assumes that the ownership over all stages has been taken over by someone else. Clears the stages sequence without deleting the stages.
 

Detailed Description

Defines logic for rendering frames from given scenes.

Rendering Process

The FrameRenderer mainly defines a sequence of rendering stages. Each stage contributes several rendering instructions to the overall rendering process. Such instructions can be the rendering of 3D objects or also something completely different, like taking care of stereoscopic rendering.

The rendering process is made up by the execution of occasionally nested render tasks. At the beginning of the process there is always exactly one render task. It's purpose is to invoke the rendering stages of the frame renderer successively. The render task API is documented here.

In the most simple case, there is only one render task all the time. An invocation to FrameRenderer::render triggers it's execution, which in turn invokes rendering on each render stage once.

However, there is an important concept about render tasks, that allows realization of more complex rendering processes: Rendering stages may fork the task they are invoked by. Such a forked task is basically a clone of the original one: It continuous processing rendering stages with the next stage that it was created by. It's purpose usually is to obtain a rendering from the succeeding stages, store it to a texture and process this texture somehow afterwards. When finished, the original task continuous with the same.

Author
Leonid Kostrykin
Date
21.2.15 - 6.3.15

Definition at line 69 of file FrameRenderer.h.

Constructor & Destructor Documentation

Carna::base::FrameRenderer::FrameRenderer ( GLContext glContext,
unsigned int  width,
unsigned int  height,
bool  fitSquare 
)

Instantiates with empty rendering stages sequence.

See also
All parameters except glContext can be changed via reshape later.
Parameters
glContextOpenGL context wrapper that this renderer will be associated with.
widthWidth of future rendered frames.
heightHeight of future rendered frames.
fitSquareIf true, the viewport will be square-shaped and centered within the frame. You will also have to update the projection matrix w.r.t. to the new aspect ratio of width and height if fitSquare is false.

Member Function Documentation

void Carna::base::FrameRenderer::render ( Camera cam) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Uses the root of cam as the scene root, which needs to be looked up first, which may take a while if cam resides deep in the scene graph.

void Carna::base::FrameRenderer::renderTexture ( const RenderTextureParams params) const

Renders rectangle that covers the current viewport, according to params. Refer to RenderTextureParams for further notes.

Warning
Based on the particular values" specified in \a params, this method might change the \ref GLContext::setShader "active shader".
void Carna::base::FrameRenderer::reshape ( unsigned int  width,
unsigned int  height,
bool  fitSquare 
)

Sets width, height and root viewport of future rendered frames.

Parameters
widthWidth of future rendered frames.
heightHeight of future rendered frames.
fitSquareIf true, the viewport will be square-shaped and centered within the frame. You will also have to update the projection matrix w.r.t. to the new aspect ratio of width and height if fitSquare is false.
void Carna::base::FrameRenderer::reshape ( unsigned int  width,
unsigned int  height 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Takes same value for fitSquare that was given last time.


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