Lugdunum  0.1.0
View.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <memory>
7 
8 namespace lug {
9 namespace Graphics {
10 namespace Render {
11 
12 namespace Camera {
13 class Camera;
14 } // Camera
15 
16 class Target;
17 
19 public:
20  // x, y, width, height => percentage of the screen
21  // TODO: Declare offset and extent outside
22  class Viewport {
23  public:
24  struct {
25  float x;
26  float y;
27  } offset;
28 
29  struct {
30  float width;
31  float height;
32  } extent;
33 
34  float minDepth;
35  float maxDepth;
36 
37  inline float getRatio() const;
38  };
39 
40  struct Scissor {
41  struct {
42  float x;
43  float y;
44  } offset;
45 
46  struct {
47  float width;
48  float height;
49  } extent;
50  };
51 
52  struct InitInfo {
56  // TODO: Clear color
57  };
58 
59 public:
60  View(const Target* renderTarget);
61 
62  View(const View&) = delete;
63  View(View&&) = delete;
64 
65  View& operator=(const View&) = delete;
66  View& operator=(View&&) = delete;
67 
68  virtual ~View() = default;
69 
70  void init(InitInfo& initInfo);
71 
72  InitInfo& getInfo();
73  const InitInfo& getInfo() const;
74 
75  const Viewport& getViewport() const;
76  const Scissor& getScissor() const;
77 
78  const Math::Vec3f& getClearColor() const;
79  void setClearColor(const Math::Vec3f& color);
80 
81  void attachCamera(Resource::SharedPtr<Camera::Camera> camera);
82  Resource::SharedPtr<Camera::Camera> getCamera() const;
83 
84  void update();
85 
86  virtual void destroy() = 0;
87  virtual bool endFrame() = 0;
88 
89 protected:
92 
93  Viewport _viewport{};
94  Scissor _scissor{};
95  Math::Vec3f _clearColor{0.0f, 0.0f, 0.0f};
97 };
98 
100 
101 } // Render
102 } // Graphics
103 } // lug
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
const Target * _renderTarget
Definition: View.hpp:90
Dummy class for a shared pointer.
Definition: Resource.hpp:66
Resource::SharedPtr< Camera::Camera > camera
Definition: View.hpp:55