lxgui
Loading...
Searching...
No Matches
gui_gl_material.hpp
1#ifndef LXGUI_GUI_GL_MATERIAL_HPP
2#define LXGUI_GUI_GL_MATERIAL_HPP
3
4#include "lxgui/gui_bounds2.hpp"
5#include "lxgui/gui_color.hpp"
6#include "lxgui/gui_material.hpp"
7#include "lxgui/utils.hpp"
8
9#include <cstdint>
10#include <memory>
11#include <vector>
12
13namespace lxgui::gui::gl {
14
21class material final : public gui::material {
22public:
29 material(const vector2ui& dimensions, wrap wrp = wrap::repeat, filter filt = filter::none);
30
39 std::uint32_t texture_handle,
40 const vector2ui& canvas_dimensions,
41 const bounds2f rect,
42 filter filt = filter::none);
43
44 material(const material& tex) = delete;
45 material(material&& tex) = delete;
46 material& operator=(const material& tex) = delete;
47 material& operator=(material&& tex) = delete;
48
50 ~material() override;
51
56 bounds2f get_rect() const override;
57
70
75 bool uses_same_texture(const gui::material& other) const override;
76
83 bool set_dimensions(const vector2ui& dimensions);
84
91 static void premultiply_alpha(std::vector<color32>& data);
92
97 void set_wrap(wrap wrp);
98
105 void set_filter(filter filt);
106
112
114 void bind() const;
115
120 void update_texture(const color32* data);
121
126 std::uint32_t get_handle() const;
127
134 static void check_availability();
135
140 static std::size_t get_max_size();
141
142private:
143 vector2ui canvas_dimensions_;
144 wrap wrap_ = wrap::repeat;
145 filter filter_ = filter::none;
146 std::uint32_t texture_handle_ = 0u;
147 bounds2f rect_;
148 bool is_owner_ = false;
149
150 static bool only_power_of_two;
151 static std::size_t maximum_size;
152};
153
154} // namespace lxgui::gui::gl
155
156#endif
A class that holds rendering data This implementation can contain either a plain color or a real Open...
material(const vector2ui &dimensions, wrap wrp=wrap::repeat, filter filt=filter::none)
Constructor for textures.
void update_texture(const color32 *data)
Updates the texture that is in GPU memory.
static void check_availability()
Checks if the machine is capable of using some features.
material & operator=(const material &tex)=delete
bounds2f get_rect() const override
Returns the pixel rect in pixels of the canvas containing this texture (if any).
~material() override
Destructor.
static std::size_t get_max_size()
Returns the maximum size available for a texture, in pixels.
material(const material &tex)=delete
bool set_dimensions(const vector2ui &dimensions)
Resizes this texture.
std::uint32_t get_handle() const
Returns the OpenGL texture handle.
bool uses_same_texture(const gui::material &other) const override
Checks if another material is based on the same texture as the current material.
vector2ui get_canvas_dimensions() const override
Returns the physical dimensions (in pixels) of the canvas containing this texture (if any).
void set_filter(filter filt)
Sets the filter mode of this texture.
material(std::uint32_t texture_handle, const vector2ui &canvas_dimensions, const bounds2f rect, filter filt=filter::none)
Constructor for atlas textures.
filter get_filter() const
Returns the filter mode of this texture.
void bind() const
Sets this material as the active one.
void set_wrap(wrap wrp)
Sets the wrap mode of this texture.
material & operator=(material &&tex)=delete
static void premultiply_alpha(std::vector< color32 > &data)
Premultiplies the texture by alpha component.
material(material &&tex)=delete
A class that holds rendering data.
Holds a single color (byte RGBA, 32 bits)
Definition gui_color.hpp:76