lxgui
Loading...
Searching...
No Matches
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 <cstdint>
10#include <memory>
11
12namespace lxgui::gui::gl {
13
15class render_target final : public gui::render_target {
16public:
23
25 ~render_target() override;
26
28 void begin() override;
29
31 void end() override;
32
37 void clear(const color& c) override;
38
43 bounds2f get_rect() const override;
44
50 bool set_dimensions(const vector2ui& dimensions) override;
51
61
68 void save_to_file(std::string filename) const override;
69
74 std::weak_ptr<gl::material> get_material();
75
80 const matrix4f& get_view_matrix() const;
81
86 static void check_availability();
87
88private:
89 static void save_rgba_to_png_(
90 const std::string& filename, const color32* data, std::size_t width, std::size_t height);
91
92 std::uint32_t fbo_handle_ = 0;
93 std::shared_ptr<gl::material> texture_;
94
95 matrix4f view_matrix_;
96};
97
98} // namespace lxgui::gui::gl
99
100#endif
Holds a single color (float RGBA, 128 bits)
Definition gui_color.hpp:13
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.
const matrix4f & get_view_matrix() const
Returns the view matrix of this render target.
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.
void save_to_file(std::string filename) const override
Saves the content of this render target into a file.
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.
std::weak_ptr< gl::material > get_material()
Returns the associated texture for rendering.
A place to render things (the screen, a texture, ...)
Holds a single color (byte RGBA, 32 bits)
Definition gui_color.hpp:76
A 4x4 matrix, used for coordinate transformations.