lxgui
gui_gl_render_target.hpp
1 #ifndef LXGUI_GUI_GL_RENDER_TARGET_HPP
2 #define LXGUI_GUI_GL_RENDER_TARGET_HPP
3 
4 #include "lxgui/gui_matrix4.hpp"
5 #include "lxgui/gui_render_target.hpp"
6 #include "lxgui/impl/gui_gl_material.hpp"
7 #include "lxgui/utils.hpp"
8 
9 #include <memory>
10 
11 namespace lxgui::gui::gl {
12 
14 class render_target final : public gui::render_target {
15 public:
22 
24  ~render_target() override;
25 
27  void begin() override;
28 
30  void end() override;
31 
36  void clear(const color& c) override;
37 
42  bounds2f get_rect() const override;
43 
49  bool set_dimensions(const vector2ui& dimensions) override;
50 
59  vector2ui get_canvas_dimensions() const override;
60 
67  void save_to_file(std::string filename) const override;
68 
73  std::weak_ptr<gl::material> get_material();
74 
79  const matrix4f& get_view_matrix() const;
80 
85  static void check_availability();
86 
87 private:
88  static void save_rgba_to_png_(
89  const std::string& filename, const color32* data, std::size_t width, std::size_t height);
90 
91  std::uint32_t fbo_handle_ = 0;
92  std::shared_ptr<gl::material> texture_;
93 
94  matrix4f view_matrix_;
95 };
96 
97 } // namespace lxgui::gui::gl
98 
99 #endif
Holds a single color (float RGBA, 128 bits)
Definition: gui_color.hpp:12
A place to render things (the screen, a texture, ...)
void end() override
Ends rendering on this target.
bool set_dimensions(const vector2ui &dimensions) override
Sets this render target's dimensions.
~render_target() override
Destructor.
bounds2f get_rect() const override
Returns this render target's pixel rect.
void begin() override
Begins rendering on this target.
render_target(const vector2ui &dimensions, material::filter filt=material::filter::none)
Constructor.
vector2ui get_canvas_dimensions() const override
Returns this render target's canvas dimension.
std::weak_ptr< gl::material > get_material()
Returns the associated texture for rendering.
void save_to_file(std::string filename) const override
Saves the content of this render target into a file.
const matrix4f & get_view_matrix() const
Returns the view matrix of this render target.
void clear(const color &c) override
Clears the content of this render_target.
static void check_availability()
Checks if the machine is capable of using render targets.
A place to render things (the screen, a texture, ...)
Holds a single color (byte RGBA, 32 bits)
Definition: gui_color.hpp:75
A 4x4 matrix, used for coordinate transformations.
Definition: gui_matrix4.hpp:13