galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
RenderTexture.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_RENDERTEXTURE_HPP_
9#define GALAXY_GRAPHICS_RENDERTEXTURE_HPP_
10
11#include <string_view>
12
13#include <glm/mat4x4.hpp>
14
16
17namespace galaxy
18{
19 namespace graphics
20 {
24 class RenderTexture final
25 {
26 public:
31
36
41
45 virtual ~RenderTexture();
46
53 void create(const int width, const int height);
54
63 void recreate(const int width = -1, const int height = -1);
64
70 void save(std::string_view file);
71
77 void bind(bool clear = true);
78
82 void unbind();
83
87 void clear();
88
96 [[nodiscard]]
97 int width() const;
98
106 [[nodiscard]]
107 int height() const;
108
114 [[nodiscard]]
115 unsigned int texture() const;
116
122 [[nodiscard]]
123 const glm::mat4& get_proj();
124
130 [[nodiscard]]
131 Framebuffer& fbo();
132
133 private:
137 RenderTexture(const RenderTexture&) = delete;
138
143
144 private:
149
154
159
163 glm::mat4 m_proj;
164 };
165 } // namespace graphics
166} // namespace galaxy
167
168#endif
OpenGL framebuffer to render to.
Draw to an opengl texture instead of the screen.
int height() const
Get texture height.
Framebuffer m_framebuffer
OpenGL framebuffer abstraction.
RenderTexture(const RenderTexture &)=delete
Copy constructor.
void unbind()
Deactivate context.
const glm::mat4 & get_proj()
Get render texture projection.
void create(const int width, const int height)
Create framebuffer and texture.
void save(std::string_view file)
Saves texture to file on disk.
unsigned int texture() const
Gets framebuffer texture.
RenderTexture & operator=(RenderTexture &&)
Move assignment operator.
RenderTexture & operator=(const RenderTexture &)=delete
Copy assignment operator.
void recreate(const int width=-1, const int height=-1)
Destroy and re-create framebuffer.
void clear()
Clear framebuffer attachments.
Framebuffer & fbo()
Get framebuffer.
virtual ~RenderTexture()
Destructor.
void bind(bool clear=true)
Activate context.
int width() const
Get texture width.
Animated.cpp galaxy.
Definition Animated.cpp:16