lxgui
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 
11 struct SDL_Renderer;
12 struct SDL_Texture;
13 
14 namespace lxgui::gui::sdl {
15 
17 class render_target final : public gui::render_target {
18 public:
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 
64  vector2ui get_canvas_dimensions() const override;
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 
99 private:
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:12
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.
std::weak_ptr< sdl::material > get_material()
Returns the associated texture for rendering.
vector2ui get_canvas_dimensions() const override
Returns this render target's canvas dimension.
SDL_Texture * get_render_texture()
Returns the underlying SDL render texture object. return The underlying SDL render texture object.
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.
void begin() override
Begins rendering on this target.
render_target(SDL_Renderer *rdr, const vector2ui &dimensions, material::filter filt=material::filter::none)
Constructor.
void end() override
Ends rendering on this target.
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.
A 4x4 matrix, used for coordinate transformations.
Definition: gui_matrix4.hpp:13