lxgui
Loading...
Searching...
No Matches
gui_sdl_render_target.hpp
1#ifndef LXGUI_GUI_SDL_RENDER_TARGET_HPP
2#define LXGUI_GUI_SDL_RENDER_TARGET_HPP
3
4#include "lxgui/gui_matrix4.hpp"
5#include "lxgui/gui_render_target.hpp"
6#include "lxgui/impl/gui_sdl_material.hpp"
7#include "lxgui/utils.hpp"
8
9#include <memory>
10
11struct SDL_Renderer;
12struct SDL_Texture;
13
14namespace lxgui::gui::sdl {
15
17class render_target final : public gui::render_target {
18public:
26 SDL_Renderer* rdr,
27 const vector2ui& dimensions,
29
31 void begin() override;
32
34 void end() override;
35
40 void clear(const color& c) override;
41
46 bounds2f get_rect() const override;
47
54 bool set_dimensions(const vector2ui& dimensions) override;
55
65
72 void save_to_file(std::string filename) const override;
73
78 std::weak_ptr<sdl::material> get_material();
79
84 const matrix4f& get_view_matrix() const;
85
91 static void check_availability(SDL_Renderer* rdr);
92
97 SDL_Texture* get_render_texture();
98
99private:
100 std::shared_ptr<sdl::material> texture_;
101 matrix4f view_matrix_;
102};
103
104} // namespace lxgui::gui::sdl
105
106#endif
Holds a single color (float RGBA, 128 bits)
Definition gui_color.hpp:13
A place to render things (the screen, a texture, ...)
A place to render things (the screen, a texture, ...)
void save_to_file(std::string filename) const override
Saves the content of this render target into a file.
SDL_Texture * get_render_texture()
Returns the underlying SDL render texture object. return The underlying SDL render texture object.
vector2ui get_canvas_dimensions() const override
Returns this render target's canvas dimension.
bool set_dimensions(const vector2ui &dimensions) override
Sets this render target's dimensions.
static void check_availability(SDL_Renderer *rdr)
Checks if the machine is capable of using render targets.
void clear(const color &c) override
Clears the content of this render_target.
std::weak_ptr< sdl::material > get_material()
Returns the associated texture for rendering.
void begin() override
Begins rendering on this target.
render_target(SDL_Renderer *rdr, const vector2ui &dimensions, material::filter filt=material::filter::none)
Constructor.
const matrix4f & get_view_matrix() const
Returns the view matrix of this render target.
void end() override
Ends rendering on this target.
bounds2f get_rect() const override
Returns this render target's pixel rect.
A 4x4 matrix, used for coordinate transformations.