A class that holds rendering data This implementation can contain either a plain color or a real OpenGL texture. It is also used by the gui::gl::render_target class to store the output data.
More...
#include <gui_gl_material.hpp>
|
static void | premultiply_alpha (std::vector< color32 > &data) |
| Premultiplies the texture by alpha component.
|
|
static void | check_availability () |
| Checks if the machine is capable of using some features.
|
|
static std::size_t | get_max_size () |
| Returns the maximum size available for a texture, in pixels.
|
|
A class that holds rendering data This implementation can contain either a plain color or a real OpenGL texture. It is also used by the gui::gl::render_target class to store the output data.
Definition at line 21 of file gui_gl_material.hpp.
◆ filter
◆ wrap
◆ material() [1/4]
Constructor for textures.
- Parameters
-
dimensions | The requested texture dimensions |
wrp | How to adjust texture coordinates that are outside the [0,1] range |
filt | Use texture filtering or not (see set_filter()) |
◆ material() [2/4]
Constructor for atlas textures.
- Parameters
-
texture_handle | The handle to the texture object of the atlas |
canvas_dimensions | The dimensions of the texture atlas |
rect | The position of this texture inside the atlas |
filt | Use texture filtering or not (see set_filter()) |
◆ material() [3/4]
lxgui::gui::gl::material::material |
( |
const material & |
tex | ) |
|
|
delete |
◆ material() [4/4]
lxgui::gui::gl::material::material |
( |
material && |
tex | ) |
|
|
delete |
◆ ~material()
lxgui::gui::gl::material::~material |
( |
| ) |
|
|
overridevirtual |
◆ bind()
void lxgui::gui::gl::material::bind |
( |
| ) |
const |
Sets this material as the active one.
◆ check_availability()
static void lxgui::gui::gl::material::check_availability |
( |
| ) |
|
|
static |
Checks if the machine is capable of using some features.
- Note
- The function checks for non power of two capability. If the graphics card doesn't support it, the material class will automatically create power of two textures.
◆ get_canvas_dimensions()
vector2ui lxgui::gui::gl::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::gl::material::get_filter |
( |
| ) |
const |
Returns the filter mode of this texture.
- Returns
- The filter mode of this texture
◆ get_handle()
std::uint32_t lxgui::gui::gl::material::get_handle |
( |
| ) |
const |
Returns the OpenGL texture handle.
- Note
- For internal use.
◆ 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_max_size()
static std::size_t lxgui::gui::gl::material::get_max_size |
( |
| ) |
|
|
static |
Returns the maximum size available for a texture, in pixels.
- Returns
- The maximum size available for a texture, in pixels
◆ get_rect()
bounds2f lxgui::gui::gl::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.
◆ 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::gl::material::premultiply_alpha |
( |
std::vector< color32 > & |
data | ) |
|
|
static |
Premultiplies the texture by alpha component.
- Parameters
-
data | The pixel data to pre-multiply |
- Note
- Premultiplied alpha is a rendering technique that allows perfect alpha blending when using render targets.
◆ set_dimensions()
bool lxgui::gui::gl::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::gl::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::gl::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::gl::material::update_texture |
( |
const color32 * |
data | ) |
|
Updates the texture that is in GPU memory.
- Parameters
-
◆ uses_same_texture()
bool lxgui::gui::gl::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: