HIRO_DRAW
Computer Graphics Structures library
hiro::draw::ElementRenderer Class Reference

Base class for rendering of geometry data. More...

Inheritance diagram for hiro::draw::ElementRenderer:
[legend]

Public Member Functions

 ElementRenderer (const hiro::draw::ElementRenderer &source)=delete
 
ElementRenderer & operator= (const hiro::draw::ElementRenderer &source)=delete
 
 ElementRenderer (hiro::draw::ElementRenderer &&) noexcept=delete
 
ElementRenderer & operator= (hiro::draw::ElementRenderer &&) noexcept=delete
 
- Public Member Functions inherited from hiro::draw::Renderer
virtual bool IsCompatibileWithStyle (const hiro::draw::Style *style)=0
 Test whether specified style is compatible with object.
 

Protected Member Functions

 ElementRenderer ()
 Protected constructor, since this class should serve only as a base class.
 
void LoadRequiredShaderPrograms (glw::ProgramList *programs) override
 Loads shader programs required by this renderer.
 
void Render (const std::string &program) override
 Specifies what happens during render.
 
virtual void OnRenderPoints ()
 Override if you wish to render points. Use the method RenderPoints to actually render.
 
virtual void OnRenderFaces ()
 Override if you wish to render faces. Use the method RenderFaces to actually render.
 
virtual void OnRenderNormals ()
 Override if you wish to render normals. Use the method RenderNormals to actually render.
 
void RenderPoints (const hiro::draw::PointsStyle &style, std::function< void(void)> render_func)
 Prepares shader according to the style and renders points using the specified render_func.
 
void RenderFaces (const hiro::draw::FacesStyle &style, std::function< void(void)> render_func)
 Prepares shader according to the style and renders faces using the specified render_func.
 
void RenderNormals (const hiro::draw::NormalsStyle &style, std::function< void(void)> render_func)
 Prepares shader according to the style and renders normals using the specified render_func.
 
- Protected Member Functions inherited from hiro::draw::Renderer
virtual void OnRenderSimple ()
 Provides the possibility to render shapes using a simple color shader. More...
 
virtual void Render2D (const std::string &program)
 Override this method to specify custom rendering behavior in 2D rendering pass.
 
virtual void OnRenderSimple2D ()
 Provides the possibility to render shapes using a simple color shader. More...
 
virtual void FillTextRenderer (hiro::draw::TextRenderer *t_renderer)
 Override this method to define texts to be rendered.
 
template<typename StyleType >
const StyleType * GetStyle () const
 Obtain currently set object style of specific type. Can be used only in Update-Render stage!
 
const Scene * GetScene () const
 

Detailed Description

Base class for rendering of geometry data.

If you wish to specify your rendering override desired "OnRender" method and render inside it.

Your own method for point rendering can be implemented something like this:

{
const auto style = GetStyle<GeometryStyle>();
if (style->render_mode == GeometryStyle::RenderMode::points
|| style->render_mode == GeometryStyle::RenderMode::wired_points)
{
PointsStyle ps;
ps.back_face_culling = style->back_face_culling;
ps.color_source = style->color_source;
ps.material = style->material;
ps.point_size = style->point_size;
vao_->Bind();
RenderPoints(ps, [&]() { vao_->DrawVertices(glw::DrawMode::points); });
vao_->Unbind();
}
}