Mountain  1.0.0
Simple C++ 2D Game Framework
render_target.hpp
1 #pragma once
2 
3 #include "Mountain/core.hpp"
4 
5 #include <Maths/matrix.hpp>
6 #include <Maths/vector2i.hpp>
7 
8 #include "Mountain/rendering/gpu_texture.hpp"
9 #include "Mountain/rendering/graphics.hpp"
10 #include "Mountain/rendering/light_source.hpp"
11 #include "Mountain/utils/color.hpp"
12 #include "Mountain/utils/list.hpp"
13 
14 namespace Mountain
15 {
17  {
18  public:
21 
23  MOUNTAIN_API RenderTarget() = default;
27  MOUNTAIN_API RenderTarget(Vector2i size, Graphics::MagnificationFilter filter);
28  MOUNTAIN_API ~RenderTarget();
29 
30  DELETE_COPY_MOVE_OPERATIONS(RenderTarget)
31 
32 
33  MOUNTAIN_API void Initialize(Vector2i size, Graphics::MagnificationFilter filter);
35  MOUNTAIN_API void Reset();
37  MOUNTAIN_API void Reset(Vector2i newSize, Graphics::MagnificationFilter newFilter);
38 
39  MOUNTAIN_API LightSource& NewLightSource();
40  MOUNTAIN_API void DeleteLightSource(const LightSource& lightSource);
41  MOUNTAIN_API void ClearLightSources();
42  MOUNTAIN_API const List<LightSource>& GetLightSources() const;
43 
48  MOUNTAIN_API void SetDebugName(std::string_view name) const;
49 
50  [[nodiscard]]
51  MOUNTAIN_API uint32_t GetTextureId() const;
52 
53  [[nodiscard]]
54  MOUNTAIN_API Graphics::GpuTexture GetGpuTexture() const;
55 
56  [[nodiscard]]
57  MOUNTAIN_API bool_t GetInitialized() const;
58 
59  [[nodiscard]]
60  MOUNTAIN_API Vector2i GetSize() const;
61  MOUNTAIN_API void SetSize(Vector2i newSize);
62 
63  [[nodiscard]]
64  MOUNTAIN_API Graphics::MagnificationFilter GetFilter() const;
65  MOUNTAIN_API void SetFilter(Graphics::MagnificationFilter newFilter);
66 
67  [[nodiscard]]
68  MOUNTAIN_API const Matrix& GetCameraMatrix() const;
69  MOUNTAIN_API void SetCameraMatrix(const Matrix& newCameraMatrix);
70 
71  [[nodiscard]]
72  MOUNTAIN_API const Vector2& GetCameraScale() const;
73 
74  private:
75  Graphics::GpuTexture m_Texture;
76  uint32_t m_Framebuffer;
77  uint32_t m_Vbo, m_Vao;
78 
79  bool_t m_Initialized = false;
80 
81  Vector2i m_Size;
82  Graphics::MagnificationFilter m_Filter;
83 
84  Matrix m_Projection;
85 
86  List<LightSource> m_LightSources;
87 
88  Matrix m_CameraMatrix = Matrix::Identity();
89  Vector2 m_CameraScale = Vector2::One();
90 
91  void Use() const;
92 
93  void UpdateDrawCamera() const;
94 
95  static Matrix ComputeProjection(Vector2i size);
96 
97  friend class Renderer;
98  };
99 }
MOUNTAIN_API void SetDebugName(std::string_view name) const
Adds a friendly debug name for this RenderTarget. This is used when debugging graphics in external ap...
Defines the Mountain::List class.
A dynamic array implementation. Wrapper around the std::vector class.
Definition: list.hpp:24
Defines multiple color structs.
Low-level interface for OpenGL textures.
Definition: gpu_texture.hpp:12
MOUNTAIN_API void Reset()
Reset the RenderTarget to an uninitialized state.
static constexpr Vector2 One() noexcept
static constexpr Color White()
Constant for White.
The Color struct represents a color in RGBA color space.
Definition: color.hpp:26
MOUNTAIN_API void Initialize(Vector2i size, Graphics::MagnificationFilter filter)
Initialize the RenderTarget with the given values.
MOUNTAIN_API RenderTarget()=default
Create an uninitialized RenderTarget.
Color ambientLight
The ambient light color applied to the entirety of the RenderTarget.
static constexpr Matrix Identity() noexcept
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22