gramods
Public Types | Public Member Functions | List of all members
gramods::gmGraphics::CallbackRenderer Class Reference

A renderer that defers rendering to a callback function. More...

#include <CallbackRenderer.hh>

Inheritance diagram for gramods::gmGraphics::CallbackRenderer:
Inheritance graph
[legend]
Collaboration diagram for gramods::gmGraphics::CallbackRenderer:
Collaboration graph
[legend]

Public Types

typedef std::function< void(void)> SetupFunction
 The signature of a setup function that prepares a renderer. More...
 
typedef std::function< void(const Camera &, const Eigen::Affine3f &)> RenderFunction
 The signature of the rendering function that provides the actual graphics. More...
 
typedef std::function< void(const Camera &, const Eigen::Affine3f &, float &, float &)> NearFarFunction
 The signature of an optional function that returns the currently optimal near and far plane distances. More...
 
- Public Types inherited from gramods::gmGraphics::Node
typedef std::vector< std::shared_ptr< Node > > list
 

Public Member Functions

void render (const Camera &camera, const Eigen::Affine3f &Mm) override
 Performs rendering of 3D objects in the scene. More...
 
void getNearFar (const Camera &camera, const Eigen::Affine3f &Mm, float &near, float &far) override
 Extracts the currently optimal near and far plane distances. More...
 
void setCallback (SetupFunction func)
 Sets the callback that should be called to set up GL for rendering. More...
 
void setCallback (RenderFunction func)
 Sets the callback that should be called upon calls to the render method. More...
 
void setCallback (NearFarFunction func)
 Sets the callback that should be called to get optimal near and far plane distances. More...
 
- Public Member Functions inherited from gramods::gmGraphics::Renderer
void addEye (Eye e)
 Add an eye to render to. More...
 
- Public Member Functions inherited from gramods::gmGraphics::Node
virtual std::vector< float > getIntersections (const IntersectionLine &line)
 Check and return intersections between the provided line and the shape represented by this node. More...
 
virtual std::string getDefaultKey () override
 Returns the default key, in Configuration, for the Object. More...
 
- Public Member Functions inherited from gramods::gmCore::Object
 Object ()
 Initializes internal data. More...
 
virtual ~Object ()
 Cleaning up internal data. More...
 
virtual void initialize ()
 Called to initialize the Object. More...
 
virtual void accept (Visitor *visitor)
 Calls the visitors apply method with this as argument. More...
 
virtual void traverse (Visitor *visitor)
 Calls the child Object's accept method, if such exist. More...
 
bool isInitialized ()
 Returns true if the Object is initialized. More...
 

Additional Inherited Members

- Static Public Attributes inherited from gramods::gmGraphics::Renderer
static gramods::gmCore::OFactory::OFactoryInformation _gm_ofi
 
- Protected Attributes inherited from gramods::gmGraphics::Renderer
std::set< Eyeeyes
 Eyes to render. More...
 

Detailed Description

A renderer that defers rendering to a callback function.

Typical usage:

auto callback = std::make_shared<gmGraphics::CallbackRenderer>();
callback->setCallback([=](Camera c){ my_render_callback(c); });
window->addRenderer(callback);

Member Typedef Documentation

◆ NearFarFunction

typedef std::function<void( const Camera &, const Eigen::Affine3f &, float &, float &)> gramods::gmGraphics::CallbackRenderer::NearFarFunction

The signature of an optional function that returns the currently optimal near and far plane distances.

This is typically used by a View if there are multiple renderers that need to be rendered with the same near and far planes for correct depth testing.

◆ RenderFunction

typedef std::function<void(const Camera &, const Eigen::Affine3f &)> gramods::gmGraphics::CallbackRenderer::RenderFunction

The signature of the rendering function that provides the actual graphics.

See also
gmGraphics::Renderer::render

◆ SetupFunction

typedef std::function<void(void)> gramods::gmGraphics::CallbackRenderer::SetupFunction

The signature of a setup function that prepares a renderer.

This is called once, the first time the render function is called by its view.

Member Function Documentation

◆ getNearFar()

void gramods::gmGraphics::CallbackRenderer::getNearFar ( const Camera camera,
const Eigen::Affine3f &  Mm,
float &  near,
float &  far 
)
inlineoverridevirtual

Extracts the currently optimal near and far plane distances.

This is typically used by a View if there are multiple renderers that need to be rendered with the same near and far planes for correct depth testing.

Implements gramods::gmGraphics::Renderer.

◆ render()

void gramods::gmGraphics::CallbackRenderer::render ( const Camera camera,
const Eigen::Affine3f &  Mm 
)
inlineoverridevirtual

Performs rendering of 3D objects in the scene.

Implements gramods::gmGraphics::Renderer.

◆ setCallback() [1/3]

void gramods::gmGraphics::CallbackRenderer::setCallback ( NearFarFunction  func)
inline

Sets the callback that should be called to get optimal near and far plane distances.

◆ setCallback() [2/3]

void gramods::gmGraphics::CallbackRenderer::setCallback ( RenderFunction  func)
inline

Sets the callback that should be called upon calls to the render method.

◆ setCallback() [3/3]

void gramods::gmGraphics::CallbackRenderer::setCallback ( SetupFunction  func)
inline

Sets the callback that should be called to set up GL for rendering.


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