BALL::VIEW::RenderSetup Class Reference

This class encapsulates a (renderer, target) pair for Scene. More...

#include <renderSetup.h>

List of all members.


Public Types

enum STEREO_SETUP { NONE, LEFT_EYE, RIGHT_EYE }

Public Member Functions

RenderSetup (Renderer *r, RenderTarget *t, Scene *scene, const Stage *stage)
RenderSetup (const RenderSetup &rs)
const RenderSetup & operator= (const RenderSetup &rs)
void init ()
Initialize renderer and target.
void resize (Size width, Size height)
Resize renderer and target.
void pauseRendering ()
Pause rendering.
void startRendering ()
This function allows to activate a paused renderer again.
bool isPaused () const
This function returns the rendering state of our renderer.
void setReceiveBufferUpdates (bool do_receive)
Prevent updating of rendering buffers.
bool receivesBufferUpdates () const
Returns the buffering state of the renderer.
void updateCamera (const Camera *camera=0)
Tells the connected renderer to update its camera.
void setOffset (const Vector3 &offset)
Sets an offset to apply to camera position and look at point.
void setStereoMode (STEREO_SETUP stereo)
This function turns the connected renderer into part of a stereo setup.
void bufferRepresentation (const Representation &rep)
Makes the target the current context and forwards the given representation to the renderer for buffering.
void removeRepresentation (const Representation &rep)
Makes the target the current context and forwards the given representation to the renderer for removal.
void renderToBuffer ()
Renders the current state into the given buffer.
bool exportPNG (const String &filename)
Render the current state into a PNG file.
void setLights (bool reset_all=false)
Calls light setup for the current renderer.
void updateBackgroundColor ()
Setup background color.
Position prepareGridTextures (const RegularData3D &grid, const ColorMap &map)
Send a grid texture to the renderer.
void removeGridTextures (const RegularData3D &grid)
Remove a grid texture from the renderer.
Vector3 mapViewportTo3D (Position x, Position y)
Compute the 3D position on the view plane corresponding to point (x,y) on the view port.
Vector2 map3DToViewport (const Vector3 &vec)
Compute the 2D position on the screen corresponding to the 3D point vec.
void pickObjects (Position x1, Position y1, Position x2, Position y2, List< GeometricObject * > &objects)
Pick all objects in the given screen rectangle.
void showRuler (bool show)
Show a simple ruler.
void useContinuousLoop (bool use_loop)
Decide between event based and (threaded) continuous loop rendering.
bool isContinuous ()
Returns the mode of the render loop.
virtual void makeCurrent ()
Ensure correct current rendering context.
virtual void run ()

Public Attributes

Renderer * renderer
RenderTarget * target

Protected Member Functions

void renderToBuffer_ ()

Protected Attributes

bool rendering_paused_
bool receive_updates_
bool use_offset_
Camera camera_
Vector3 camera_offset_
STEREO_SETUP stereo_setup_
bool use_continuous_loop_
Scene * scene_
Stage const * stage_
Mutex render_mutex_
Size width_
Size height_
bool do_resize_
bool show_ruler_
GLRenderWindow * gl_target_

Detailed Description

This class encapsulates a (renderer, target) pair for Scene.

Please try to call functions inside this class instead of working with the renderers and targets directly to ensure thread safety.


Member Function Documentation

void BALL::VIEW::RenderSetup::bufferRepresentation ( const Representation & rep )

Makes the target the current context and forwards the given representation to the renderer for buffering.

If the renderer is not receiving buffer updates, this is a noop.

virtual void BALL::VIEW::RenderSetup::makeCurrent ( ) [virtual]

Ensure correct current rendering context.

If the target type uses a GL context, this is made current if necessary. If the target does not need GL, this function is a noop.

void BALL::VIEW::RenderSetup::pauseRendering ( )

Pause rendering.

This function allows to skip rendering while still buffering representations. Thus, a paused renderer will still receive all updates to representations, it will just not display anything.

Position BALL::VIEW::RenderSetup::prepareGridTextures ( const RegularData3D & grid,
const ColorMap & map
)

Send a grid texture to the renderer.

If the current renderer can not handle this kind of object, this is a noop.

void BALL::VIEW::RenderSetup::removeGridTextures ( const RegularData3D & grid )

Remove a grid texture from the renderer.

If the current renderer can not handle this kind of object, this is a noop.

void BALL::VIEW::RenderSetup::removeRepresentation ( const Representation & rep )

Makes the target the current context and forwards the given representation to the renderer for removal.

If the renderer is not receiving buffer updates, this is a noop.

void BALL::VIEW::RenderSetup::renderToBuffer ( )

Renders the current state into the given buffer.

Please note that this function only does anything when rendering is event-based, and if the renderer is not paused. If continuous rendering is set to true, the updates will be performed in a continuous loop instead and this function will immediately return.

void BALL::VIEW::RenderSetup::setOffset ( const Vector3 & offset )

Sets an offset to apply to camera position and look at point.

Please note that the offset is interpreted as relative to the camera with components (right, up, view) and will be updated at each position change.

void BALL::VIEW::RenderSetup::setReceiveBufferUpdates ( bool do_receive )

Prevent updating of rendering buffers.

This function allows to prevent the renderer from buffering or deleting representations.

Please note that this is potentially dangerous, since the renderer will not be made aware of deleted representations. Callers should make sure that the renderer state is effectively reset upon reactivating this switch.

A common use case for this function is to support two render targets sharing one render context, where we want to prevent the second target from rebuffering all representations already seen by the first.

void BALL::VIEW::RenderSetup::setStereoMode ( STEREO_SETUP stereo )

This function turns the connected renderer into part of a stereo setup.

Depending on the value set here, renderers will be passed additional information upon update camera to set eye separation and focal distance or to prepare correct frustra.

void BALL::VIEW::RenderSetup::showRuler ( bool show )

Show a simple ruler.

If supported by the renderer implementation, this function can be used to produce a simple ruler that is rendered together with the other representations. The main use of this function is in the edit mode, where it can help to straighten-up structures and to correctly estimate angles and distances.

void BALL::VIEW::RenderSetup::startRendering ( )

This function allows to activate a paused renderer again.

Please note that the corresponding window will not be automatically updated. This has to be performed by the caller.

void BALL::VIEW::RenderSetup::updateCamera ( const Camera * camera = 0 )

Tells the connected renderer to update its camera.

This function applies transformations like adding an offset to camera position and view point before handing over the camera to the renderer.


Generated on Thu Aug 6 18:31:00 2009 for BALL by doxygen 1.5.8