HIRO_DRAW
Computer Graphics Structures library
Renderer.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_RENDERER_H
7 #define HIRO_DRAW_RENDERER_H
8 #include <set>
9 #include <memory>
10 
11 #include <glm/glm.hpp>
12 
13 #include <GLW/ShaderProgramList.h>
14 #include <COGS/Color.h>
15 #include <COGS/MaterialModel.h>
16 #include <COGS/Transform.h>
17 #include <HIRO_DRAW/PrimitiveDatabase.h>
18 
19 
20 
21 namespace hiro::draw
22 {
23  class TextRenderer;
24  class Scene;
25 
27  struct HIRO_DRAW_API Style
28  {
30  bool visible = true;
32  cogs::Transform transform;
33 
34  virtual ~Style() = default;
36  virtual bool ReadFromStream(std::istream &str);
38  virtual void WriteToStream(std::ostream &str);
39  protected:
41  bool ReadVersion(std::istream &str, const uint32_t expected_version);
42  };
43 
44 
45 
47  class HIRO_DRAW_API Renderer
48  {
49  friend class RenderSystem;
50  public:
51  Renderer();
53  virtual bool IsCompatibileWithStyle(const hiro::draw::Style *style) = 0;
54 
55  protected:
57  virtual void LoadRequiredShaderPrograms(glw::ProgramList *programs);
59  virtual void Render(const std::string &program);
60 
72  virtual void OnRenderSimple();
73 
75  virtual void Render2D(const std::string &program);
87  virtual void OnRenderSimple2D();
88 
90  virtual void FillTextRenderer(hiro::draw::TextRenderer *t_renderer);
91 
93  template <typename StyleType>
94  const StyleType *GetStyle() const;
95 
96  const Scene *GetScene() const;
97 
98  private: // changes to this section are made only by RenderSystem
99  const Style *style_;
100  const Scene *scene_;
101  };
102 
103  template <typename StyleType>
104  const StyleType *hiro::draw::Renderer::GetStyle() const
105  {
106  return static_cast<const StyleType *>(style_);
107  }
108 
109 
110 
111  using PStyle = std::shared_ptr<hiro::draw::Style>;
112  using PRenderer = std::shared_ptr<hiro::draw::Renderer>;
113 
114 }
115 
116 #endif /* !HIRO_DRAW_RENDERER_H */
Responsible for rendering texts.
Definition: TextRenderer.h:47
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
const StyleType * GetStyle() const
Obtain currently set object style of specific type. Can be used only in Update-Render stage! ...
Definition: Renderer.h:104
Base class for setting rendering style of an arbitrary render object.
Definition: Renderer.h:27
cogs::Transform transform
Model transformation applied to the renderer. In shader will appear as MODEL_MATRIX.
Definition: Renderer.h:32
Class responsible for rendering loop implementation and its optimization.
Definition: RenderSystem.h:42
Defines rendering viewport, contains multiple object instances and a camera.
Definition: Scene.h:92
Abstract base class for an arbitrary renderer object.
Definition: Renderer.h:47