lxgui
|
A class that holds rendering data This implementation can contain either a plain color or a real SDL_Texture. It is also used by the gui::sdl::render_target class to store the output data. More...
#include <gui_sdl_material.hpp>
Public Types | |
enum class | wrap { repeat , clamp } |
enum class | filter { none , linear } |
Public Member Functions | |
material (SDL_Renderer *rdr, const vector2ui &dimensions, bool is_render_target=false, wrap wrp=wrap::repeat, filter filt=filter::none) | |
Constructor for textures. | |
material (SDL_Renderer *rdr, const std::string &file_name, bool is_pre_multiplied_alpha_supported, wrap wrp=wrap::repeat, filter filt=filter::none) | |
Constructor for textures. | |
material (SDL_Renderer *rdr, SDL_Texture *tex, const bounds2f &rect, filter filt=filter::none) | |
Constructor for atlas textures. | |
material (const material &tex)=delete | |
material (material &&tex)=delete | |
material & | operator= (const material &tex)=delete |
material & | operator= (material &&tex)=delete |
~material () noexcept override | |
Destructor. | |
bounds2f | get_rect () const override |
Returns the pixel rect in pixels of the canvas containing this texture (if any). | |
vector2ui | get_canvas_dimensions () const override |
Returns the physical dimensions (in pixels) of the canvas containing this texture (if any). | |
bool | uses_same_texture (const gui::material &other) const override |
Checks if another material is based on the same texture as the current material. | |
bool | set_dimensions (const vector2ui &dimensions) |
Resizes this texture. | |
void | set_wrap (wrap wrp) |
Sets the wrap mode of this texture. | |
void | set_filter (filter filt) |
Sets the filter mode of this texture. | |
filter | get_filter () const |
Returns the filter mode of this texture. | |
wrap | get_wrap () const |
Return the wrap mode of this texture. | |
SDL_Texture * | get_texture () const |
Returns the underlying SDL texture object. return The underlying SDL texture object. | |
SDL_Texture * | get_render_texture () |
Returns the underlying SDL texture object (for render target). return The underlying SDL texture object (for render target) | |
SDL_Renderer * | get_renderer () |
Returns the SDL renderer object that this material was created on. return The SDL renderer object that this material was created on. | |
color32 * | lock_pointer (std::size_t *pitch=nullptr) |
Returns a pointer to the texture data, which can be modified. | |
const color32 * | lock_pointer (std::size_t *pitch=nullptr) const |
Returns a pointer to the texture data, which can be modified. | |
void | unlock_pointer () const |
Stops modifying the texture data and update the texture in GPU memory. | |
vector2f | get_canvas_uv (const vector2f &texture_uv, bool from_normalized) const |
Returns normalized UV coordinates on the canvas, given local UV coordinates. | |
vector2f | get_local_uv (const vector2f &canvas_uv, bool as_normalized) const |
Returns local UV coordinates on the texture, given canvas UV coordinates. | |
bool | is_in_atlas () const |
Checks if the material is embedded in an atlas. | |
Static Public Member Functions | |
static void | premultiply_alpha (SDL_Surface *data) |
Premultiplies an image by its alpha component. | |
static int | get_premultiplied_alpha_blend_mode () |
Returns the SDL blend mode corresponding to pre-multiplied alpha. | |
Protected Attributes | |
bool | is_atlas_ = false |
A class that holds rendering data This implementation can contain either a plain color or a real SDL_Texture. It is also used by the gui::sdl::render_target class to store the output data.
Definition at line 24 of file gui_sdl_material.hpp.
|
stronginherited |
Enumerator | |
---|---|
none | |
linear |
Definition at line 20 of file gui_material.hpp.
|
stronginherited |
Enumerator | |
---|---|
repeat | |
clamp |
Definition at line 18 of file gui_material.hpp.
lxgui::gui::sdl::material::material | ( | SDL_Renderer * | rdr, |
const vector2ui & | dimensions, | ||
bool | is_render_target = false , |
||
wrap | wrp = wrap::repeat , |
||
filter | filt = filter::none |
||
) |
Constructor for textures.
rdr | The SDL render to create the material for |
dimensions | The requested texture dimensions |
is_render_target | Create the material for a render target or only for display |
wrp | How to adjust texture coordinates that are outside the [0,1] range |
filt | Use texture filtering or not (see set_filter()) |
lxgui::gui::sdl::material::material | ( | SDL_Renderer * | rdr, |
const std::string & | file_name, | ||
bool | is_pre_multiplied_alpha_supported, | ||
wrap | wrp = wrap::repeat , |
||
filter | filt = filter::none |
||
) |
Constructor for textures.
rdr | The SDL render to create the material for |
file_name | The file from which the texture data is loaded |
is_pre_multiplied_alpha_supported | 'true' if the renderer supports pre-multipled alpha |
wrp | How to adjust texture coordinates that are outside the [0,1] range |
filt | Use texture filtering or not (see set_filter()) |
lxgui::gui::sdl::material::material | ( | SDL_Renderer * | rdr, |
SDL_Texture * | tex, | ||
const bounds2f & | rect, | ||
filter | filt = filter::none |
||
) |
Constructor for atlas textures.
rdr | The SDL render to create the material for |
tex | The texture object of the atlas |
rect | The position of this texture inside the atlas |
filt | Use texture filtering or not (see set_filter()) |
|
delete |
|
delete |
|
overridevirtualnoexcept |
Destructor.
Reimplemented from lxgui::gui::material.
|
overridevirtual |
Returns the physical dimensions (in pixels) of the canvas containing this texture (if any).
Implements lxgui::gui::material.
|
inherited |
Returns normalized UV coordinates on the canvas, given local UV coordinates.
texture_uv | The original UV coordinates, local to this texture |
from_normalized | Set to 'true' if input coordinates are normalized |
Definition at line 7 of file gui_material.cpp.
filter lxgui::gui::sdl::material::get_filter | ( | ) | const |
Returns the filter mode of this texture.
|
inherited |
Returns local UV coordinates on the texture, given canvas UV coordinates.
canvas_uv | The canvas UV coordinates |
as_normalized | Set to 'true' if output coordinates should be normalized |
Definition at line 20 of file gui_material.cpp.
|
static |
Returns the SDL blend mode corresponding to pre-multiplied alpha.
|
overridevirtual |
Returns the pixel rect in pixels of the canvas containing this texture (if any).
Implements lxgui::gui::material.
SDL_Texture * lxgui::gui::sdl::material::get_render_texture | ( | ) |
Returns the underlying SDL texture object (for render target). return The underlying SDL texture object (for render target)
SDL_Renderer * lxgui::gui::sdl::material::get_renderer | ( | ) |
Returns the SDL renderer object that this material was created on. return The SDL renderer object that this material was created on.
SDL_Texture * lxgui::gui::sdl::material::get_texture | ( | ) | const |
Returns the underlying SDL texture object. return The underlying SDL texture object.
wrap lxgui::gui::sdl::material::get_wrap | ( | ) | const |
Return the wrap mode of this texture.
|
inherited |
Checks if the material is embedded in an atlas.
Definition at line 33 of file gui_material.cpp.
color32 * lxgui::gui::sdl::material::lock_pointer | ( | std::size_t * | pitch = nullptr | ) |
Returns a pointer to the texture data, which can be modified.
pitch | An output pointer to the size (in bytes) of a row (ignored if nullptr) |
const color32 * lxgui::gui::sdl::material::lock_pointer | ( | std::size_t * | pitch = nullptr | ) | const |
Returns a pointer to the texture data, which can be modified.
pitch | An output pointer to the size (in bytes) of a row (ignored if nullptr) |
|
static |
Premultiplies an image by its alpha component.
bool lxgui::gui::sdl::material::set_dimensions | ( | const vector2ui & | dimensions | ) |
Resizes this texture.
dimensions | The new texture dimensions |
void lxgui::gui::sdl::material::set_filter | ( | filter | filt | ) |
Sets the filter mode of this texture.
filt | Use texture filtering or not |
void lxgui::gui::sdl::material::set_wrap | ( | wrap | wrp | ) |
Sets the wrap mode of this texture.
wrp | How to adjust texture coordinates that are outside the [0,1] range |
void lxgui::gui::sdl::material::unlock_pointer | ( | ) | const |
Stops modifying the texture data and update the texture in GPU memory.
|
overridevirtual |
Checks if another material is based on the same texture as the current material.
Implements lxgui::gui::material.
|
protectedinherited |
Definition at line 93 of file gui_material.hpp.