Carna
Version 3.0.1
|
Defines logic for rendering frames from given scenes. More...
#include <FrameRenderer.h>
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. | |
GLContext & | glContext () 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 Viewport & | viewport () 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 ¶ms) 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. | |
![]() | |
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. | |
RenderStage & | stageAt (std::size_t position) const |
References the stage at position within the rendering stages sequence. | |
template<typename RenderStage > | |
Aggregation< RenderStage > | findStage () 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 | |
![]() | |
void | releaseStages () |
Assumes that the ownership over all stages has been taken over by someone else. Clears the stages sequence without deleting the stages. | |
Defines logic for rendering frames from given scenes.
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.
Definition at line 69 of file FrameRenderer.h.
Carna::base::FrameRenderer::FrameRenderer | ( | GLContext & | glContext, |
unsigned int | width, | ||
unsigned int | height, | ||
bool | fitSquare | ||
) |
Instantiates with empty rendering stages sequence.
glContext | OpenGL context wrapper that this renderer will be associated with. |
width | Width of future rendered frames. |
height | Height of future rendered frames. |
fitSquare | If 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::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.
void Carna::base::FrameRenderer::reshape | ( | unsigned int | width, |
unsigned int | height, | ||
bool | fitSquare | ||
) |
Sets width, height and root viewport of future rendered frames.
width | Width of future rendered frames. |
height | Height of future rendered frames. |
fitSquare | If 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.
Documentation generated by Doxygen