HIRO_DRAW
Computer Graphics Structures library
FrustumRenderer.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_FRUSTUM_RENDERER_H
7 #define HIRO_DRAW_FRUSTUM_RENDERER_H
8 #include <COGS/Frustum.h>
9 #include <GLW/ArrayObject.h>
10 #include <HIRO_DRAW/Renderer.h>
11 
12 
13 
14 namespace hiro::draw
15 {
16 
18  struct HIRO_DRAW_API FrustumStyle : public hiro::draw::Style
19  {
21  float line_thickness{ 1.0f };
23  cogs::Color3f near_color{ cogs::color::GRAY50 };
25  cogs::Color3f far_color{ cogs::color::GRAY50 };
27  bool draw_eye_lines{ true };
29  cogs::Color3f eye_lines_color{ cogs::color::GRAY50 };
31  virtual bool ReadFromStream(std::istream &str) override;
33  virtual void WriteToStream(std::ostream &str) override;
34  };
35 
36 
37 
39  class HIRO_DRAW_API FrustumRenderer : public hiro::draw::Renderer
40  {
41  public:
43  FrustumRenderer() = default;
45  FrustumRenderer(const cogs::Frustum &frustum);
46 
48  FrustumRenderer &operator=(const hiro::draw::FrustumRenderer &) = delete;
49  FrustumRenderer(hiro::draw::FrustumRenderer &&) noexcept = delete;
50  FrustumRenderer &operator=(hiro::draw::FrustumRenderer &&) noexcept = delete;
51  virtual ~FrustumRenderer() = default;
52 
54  void SetFrustum(const cogs::Frustum &frustum);
56  bool IsCompatibileWithStyle(const hiro::draw::Style *style) override;
57 
58  protected:
60  void OnRenderSimple() override;
61 
62  private:
63  glw::PArrayObject line_vao_;
64  glw::ArrayObject::BufferName color_buffer_;
65  std::vector<cogs::Color3f> colors_;
66  void UpdateColors(const FrustumStyle *style);
67  };
68 
69 
70 
72  using PFrustumStyle = std::shared_ptr<hiro::draw::FrustumStyle>;
74  using PFrustumRenderer = std::shared_ptr<hiro::draw::FrustumRenderer>;
75 
76 }
77 
78 #endif /* !HIRO_DRAW_FRUSTUM_RENDERER_H */
std::shared_ptr< hiro::draw::FrustumStyle > PFrustumStyle
Shared pointer to an object of the type FrustumStyle.
Definition: FrustumRenderer.h:72
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
Base class for setting rendering style of an arbitrary render object.
Definition: Renderer.h:27
std::shared_ptr< hiro::draw::FrustumRenderer > PFrustumRenderer
Shared pointer to an object of the type FrustumRenderer.
Definition: FrustumRenderer.h:74
Renderer used for rendering cogs::Frustum.
Definition: FrustumRenderer.h:39
Abstract base class for an arbitrary renderer object.
Definition: Renderer.h:47
Stylization of the rendered frustum.
Definition: FrustumRenderer.h:18