# class hiro::draw::ElementRenderer

## Overview

Base class for rendering of geometry data. More…

    #include <ElementRenderer.h>

    class ElementRenderer: public hiro::draw::Renderer {
    public:
        // construction

        ElementRenderer(const hiro::draw::ElementRenderer& source);
        ElementRenderer(hiro::draw::ElementRenderer&&);
        virtual ~ElementRenderer();

        // methods

        ElementRenderer& operator=(const hiro::draw::ElementRenderer& source);
        ElementRenderer& operator=(hiro::draw::ElementRenderer&&);

    protected:
        // construction

        ElementRenderer();

        // methods

        virtual void LoadRequiredShaderPrograms(glw::ProgramList* programs);
        virtual void Render(const std::string& program);
        virtual void OnRenderPoints();
        virtual void OnRenderFaces();
        virtual void OnRenderNormals();
        void RenderPoints(const hiro::draw::PointsStyle& style, std::function<void(void)> render_func);
        void RenderFaces(const hiro::draw::FacesStyle& style, std::function<void(void)> render_func);
        void RenderNormals(const hiro::draw::NormalsStyle& style, std::function<void(void)> render_func);
    };

### Inherited Members

    public:
        // methods

        virtual bool IsCompatibileWithStyle(const hiro::draw::Style* style) = 0;

    protected:
        // methods

        virtual void LoadRequiredShaderPrograms(glw::ProgramList* programs);
        virtual void Render(const std::string& program);
        virtual void OnRenderSimple();
        virtual void Render2D(const std::string& program);
        virtual void OnRenderSimple2D();
        virtual void FillTextRenderer(hiro::draw::TextRenderer* t_renderer);

        template <typename StyleType>
        const StyleType* GetStyle() const;

        const Scene* GetScene() const;

## Detailed Documentation

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:

    void hiro::draw::GeometryRenderer::OnRenderPoints()
    {
      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();
      }
    }

### Construction

    ElementRenderer()

Protected constructor, since this class should serve only as a base class.

### Methods

    virtual void LoadRequiredShaderPrograms(glw::ProgramList* programs)

Loads shader programs required by this renderer.

    virtual void Render(const std::string& program)

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.