A class that holds rendering data This implementation can contain either a plain color or a real sf::Texture. It is also used by the gui::sfml::render_target class to store the output data.
More...
#include <gui_sfml_material.hpp>
|
| material (const vector2ui &dimensions, bool is_render_target, wrap wrp=wrap::repeat, filter filt=filter::none) |
| Constructor for textures.
|
|
| material (const sf::Image &data, wrap wrp=wrap::repeat, filter filt=filter::none) |
| Constructor for textures.
|
|
| material (const std::string &file_name, wrap wrp=wrap::repeat, filter filt=filter::none) |
| Constructor for textures.
|
|
| material (const sf::Texture &texture, const bounds2f &location, 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 |
|
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.
|
|
void | update_texture (const color32 *data) |
| Updates the texture that is in GPU memory.
|
|
sf::RenderTexture * | get_render_texture () |
| Returns the underlying SFML render texture object. return The underlying SFML render texture object.
|
|
const sf::Texture * | get_texture () const |
| Returns the underlying SFML texture object. return The underlying SFML texture object.
|
|
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 void | premultiply_alpha (sf::Image &data) |
| Premultiplies an image by its alpha component.
|
|
A class that holds rendering data This implementation can contain either a plain color or a real sf::Texture. It is also used by the gui::sfml::render_target class to store the output data.
Definition at line 23 of file gui_sfml_material.hpp.
◆ filter
◆ wrap
◆ material() [1/6]
Constructor for textures.
- Parameters
-
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()) |
◆ material() [2/6]
Constructor for textures.
- Parameters
-
data | The image data to use as texture |
wrp | How to adjust texture coordinates that are outside the [0,1] range |
filt | Use texture filtering or not (see set_filter()) |
◆ material() [3/6]
Constructor for textures.
- Parameters
-
file_name | The file from which the texture data is loaded |
wrp | How to adjust texture coordinates that are outside the [0,1] range |
filt | Use texture filtering or not (see set_filter()) |
◆ material() [4/6]
Constructor for atlas textures.
- Parameters
-
texture | The atlas texture holding this material's texture |
location | The location of the texture inside the atlas texture (in pixels) |
filt | Use texture filtering or not (see set_filter()) |
◆ material() [5/6]
lxgui::gui::sfml::material::material |
( |
const material & |
tex | ) |
|
|
delete |
◆ material() [6/6]
lxgui::gui::sfml::material::material |
( |
material && |
tex | ) |
|
|
delete |
◆ get_canvas_dimensions()
vector2ui lxgui::gui::sfml::material::get_canvas_dimensions |
( |
| ) |
const |
|
overridevirtual |
Returns the physical dimensions (in pixels) of the canvas containing this texture (if any).
- Returns
- The physical dimensions (in pixels) of the canvas containing this (if any)
- Note
- When a texture is loaded, most of the time it will fill the entire "canvas", namely, the 2D pixel array containing the texture data. However, some old hardware don't support textures that have non power-of-two dimensions. If the user creates a material for such a texture, the gui::renderer will create a bigger canvas that has power-of-two dimensions, and store the texture in it. Likewise, if a texture is placed in a wider texture atlas, the canvas will contain more than one texture.
Implements lxgui::gui::material.
◆ get_canvas_uv()
vector2f lxgui::gui::material::get_canvas_uv |
( |
const vector2f & |
texture_uv, |
|
|
bool |
from_normalized |
|
) |
| const |
|
inherited |
Returns normalized UV coordinates on the canvas, given local UV coordinates.
- Parameters
-
texture_uv | The original UV coordinates, local to this texture |
from_normalized | Set to 'true' if input coordinates are normalized |
- Note
- Normalized coordinates range from 0 to 1, with 1 corresponding to the width/height of the texture, while non-normalized coordinates are in pixels.
Definition at line 7 of file gui_material.cpp.
◆ get_filter()
filter lxgui::gui::sfml::material::get_filter |
( |
| ) |
const |
Returns the filter mode of this texture.
- Returns
- The filter mode of this texture
◆ get_local_uv()
vector2f lxgui::gui::material::get_local_uv |
( |
const vector2f & |
canvas_uv, |
|
|
bool |
as_normalized |
|
) |
| const |
|
inherited |
Returns local UV coordinates on the texture, given canvas UV coordinates.
- Parameters
-
canvas_uv | The canvas UV coordinates |
as_normalized | Set to 'true' if output coordinates should be normalized |
- Note
- Normalized coordinates range from 0 to 1, with 1 corresponding to the width/height of the texture, while non-normalized coordinates are in pixels.
Definition at line 20 of file gui_material.cpp.
◆ get_rect()
bounds2f lxgui::gui::sfml::material::get_rect |
( |
| ) |
const |
|
overridevirtual |
Returns the pixel rect in pixels of the canvas containing this texture (if any).
- Returns
- The pixel rect in pixels of the canvas containing this texture (if any)
Implements lxgui::gui::material.
◆ get_render_texture()
sf::RenderTexture * lxgui::gui::sfml::material::get_render_texture |
( |
| ) |
|
Returns the underlying SFML render texture object. return The underlying SFML render texture object.
◆ get_texture()
const sf::Texture * lxgui::gui::sfml::material::get_texture |
( |
| ) |
const |
Returns the underlying SFML texture object. return The underlying SFML texture object.
◆ is_in_atlas()
bool lxgui::gui::material::is_in_atlas |
( |
| ) |
const |
|
inherited |
Checks if the material is embedded in an atlas.
- Returns
- 'true' if the material is inside an atlas, 'false' otherwise.
Definition at line 33 of file gui_material.cpp.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ premultiply_alpha()
static void lxgui::gui::sfml::material::premultiply_alpha |
( |
sf::Image & |
data | ) |
|
|
static |
Premultiplies an image by its alpha component.
- Note
- Premultiplied alpha is a rendering technique that allows perfect alpha blending when using render targets.
◆ set_dimensions()
bool lxgui::gui::sfml::material::set_dimensions |
( |
const vector2ui & |
dimensions | ) |
|
Resizes this texture.
- Parameters
-
dimensions | The new texture dimensions |
- Returns
- 'true' if the function had to re-create a new texture object
- Note
- All the previous data that was stored in this texture will be lost.
◆ set_filter()
void lxgui::gui::sfml::material::set_filter |
( |
filter |
filt | ) |
|
Sets the filter mode of this texture.
- Parameters
-
filt | Use texture filtering or not |
- Note
- When texture filtering is disabled, enlarged textures get pixelated. Else, the GPU uses an averaging algorithm to blur the pixels.
◆ set_wrap()
void lxgui::gui::sfml::material::set_wrap |
( |
wrap |
wrp | ) |
|
Sets the wrap mode of this texture.
- Parameters
-
wrp | How to adjust texture coordinates that are outside the [0,1] range |
◆ update_texture()
void lxgui::gui::sfml::material::update_texture |
( |
const color32 * |
data | ) |
|
Updates the texture that is in GPU memory.
- Parameters
-
◆ uses_same_texture()
bool lxgui::gui::sfml::material::uses_same_texture |
( |
const gui::material & |
other | ) |
const |
|
overridevirtual |
Checks if another material is based on the same texture as the current material.
- Returns
- 'true' if both materials use the same texture, 'false' otherwise
Implements lxgui::gui::material.
◆ is_atlas_
bool lxgui::gui::material::is_atlas_ = false |
|
protectedinherited |
The documentation for this class was generated from the following file: