HIRO_DRAW
Computer Graphics Structures library
ElementRenderer.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef HIRO_DRAW_ELEMENT_RENDERER_H
7 #define HIRO_DRAW_ELEMENT_RENDERER_H
8 #include <GLW/Texture.h>
9 #include <GLW/UniformBuffer.h>
10 #include <HIRO_DRAW/Renderer.h>
11 #include <HIRO_DRAW/ShaderApi.h>
12 
13 
14 
15 namespace hiro::draw
16 {
17 
19  enum class ColorSource : int32_t
20  {
21  material = 0,
22  positions = 1,
23  normals = 2,
24  custom = 3,
25  normals_n = 4,
26  checkerboard = 5,
27  albedo_texture = 6
28  };
29 
30 
31 
33  struct PointsStyle
34  {
38  bool back_face_culling = false;
40  float point_size = 10.0f;
43  };
44 
45 
46 
48  struct FacesStyle
49  {
51  enum class NormalSource
52  {
53  flat_normals = 0,
54  point_normals = 1,
55  normal_texture = 2
56  };
57 
59  bool back_face_culling = false;
61  bool wireframe = false;
62 
68  glw::PTexture2D albedo_texture = nullptr;
69 
73  glw::PTexture2D normal_texture = nullptr;
74 
76  bool use_matcap = false;
78  glw::PTexture2D matcap_sampler = nullptr;
79  };
80 
81 
82 
84  struct NormalsStyle
85  {
87  cogs::Color3f color = cogs::color::BLACK;
89  float length = 0.1f;
90  };
91 
92 
93 
120  class HIRO_DRAW_API ElementRenderer : public hiro::draw::Renderer
121  {
122  public:
123  ElementRenderer(const hiro::draw::ElementRenderer &source) = delete;
124  ElementRenderer &operator=(const hiro::draw::ElementRenderer &source) = delete;
125  ElementRenderer(hiro::draw::ElementRenderer &&) noexcept = delete;
126  ElementRenderer &operator=(hiro::draw::ElementRenderer &&) noexcept = delete;
127  virtual ~ElementRenderer() = default;
128 
129  protected:
131  ElementRenderer();
132 
134  void LoadRequiredShaderPrograms(glw::ProgramList *programs) override;
136  void Render(const std::string &program) override;
137 
139  virtual void OnRenderPoints();
141  virtual void OnRenderFaces();
143  virtual void OnRenderNormals();
144 
146  void RenderPoints(const hiro::draw::PointsStyle &style, std::function<void(void)> render_func);
148  void RenderFaces(const hiro::draw::FacesStyle &style, std::function<void(void)> render_func);
150  void RenderNormals(const hiro::draw::NormalsStyle &style, std::function<void(void)> render_func);
151 
152  private:
154  glw::UniformBuffer<hiro::shader::Material> material_ubo_;
155  };
156 
157 }
158 
159 #endif /* !HIRO_DRAW_ELEMENT_RENDERER_H */
Base class for rendering of geometry data.
Definition: ElementRenderer.h:120
Raw 3D normals are used to represent colors.
Color is taken from the material.
Normal vector rendering stylization.
Definition: ElementRenderer.h:84
Point rendering stylization.
Definition: ElementRenderer.h:33
Checkerboard texture used to get colors.
Face rendering stylization.
Definition: ElementRenderer.h:48
hiro::shader::Material material
Material setting for the faces.
Definition: ElementRenderer.h:64
ColorSource
Available sources of color information.
Definition: ElementRenderer.h:19
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
Raw 3D positions are used to represent colors.
Albedo texture used to get colors.
hiro::shader::Material material
Material setting for the points.
Definition: ElementRenderer.h:36
NormalSource
Available sources of normal vector.
Definition: ElementRenderer.h:51
Normals are calculated from face orientations.
Properties of a simple phong material.
Definition: ShaderApi.h:93
Vertex color attribute used to get colors.
Abstract base class for an arbitrary renderer object.
Definition: Renderer.h:47