lxgui
Public Types | Public Member Functions | Protected Attributes | List of all members
lxgui::gui::material Class Referenceabstract

A class that holds rendering data. More...

#include <gui_material.hpp>

Inheritance diagram for lxgui::gui::material:
lxgui::gui::gl::material lxgui::gui::sdl::material lxgui::gui::sfml::material

Public Types

enum class  wrap { repeat , clamp }
 
enum class  filter { none , linear }
 

Public Member Functions

 material (bool is_atlas)
 Constructor. More...
 
virtual ~material ()=default
 Destructor. More...
 
 material (const material &)=delete
 Non-copiable. More...
 
 material (material &&)=delete
 Non-movable. More...
 
materialoperator= (const material &)=delete
 Non-copiable. More...
 
materialoperator= (material &&)=delete
 Non-movable. More...
 
virtual bounds2f get_rect () const =0
 Returns the pixel rect in pixels of the canvas containing this texture (if any). More...
 
virtual vector2ui get_canvas_dimensions () const =0
 Returns the physical dimensions (in pixels) of the canvas containing this texture (if any). More...
 
virtual bool uses_same_texture (const material &other) const =0
 Checks if another material is based on the same texture as the current material. More...
 
vector2f get_canvas_uv (const vector2f &texture_uv, bool from_normalized) const
 Returns normalized UV coordinates on the canvas, given local UV coordinates. More...
 
vector2f get_local_uv (const vector2f &canvas_uv, bool as_normalized) const
 Returns local UV coordinates on the texture, given canvas UV coordinates. More...
 
bool is_in_atlas () const
 Checks if the material is embedded in an atlas. More...
 

Protected Attributes

bool is_atlas_ = false
 

Detailed Description

A class that holds rendering data.

This is an abstract class that must be implemented and created by the corresponding gui::renderer.

Definition at line 16 of file gui_material.hpp.

Member Enumeration Documentation

◆ filter

Enumerator
none 
linear 

Definition at line 20 of file gui_material.hpp.

◆ wrap

Enumerator
repeat 
clamp 

Definition at line 18 of file gui_material.hpp.

Constructor & Destructor Documentation

◆ material() [1/3]

lxgui::gui::material::material ( bool  is_atlas)
explicit

Constructor.

Parameters
is_atlas'true' if this material comes from an atlas, 'false' otherwise

Definition at line 5 of file gui_material.cpp.

◆ ~material()

virtual lxgui::gui::material::~material ( )
virtualdefault

Destructor.

Reimplemented in lxgui::gui::gl::material, and lxgui::gui::sdl::material.

◆ material() [2/3]

lxgui::gui::material::material ( const material )
delete

Non-copiable.

◆ material() [3/3]

lxgui::gui::material::material ( material &&  )
delete

Non-movable.

Member Function Documentation

◆ get_canvas_dimensions()

virtual vector2ui lxgui::gui::material::get_canvas_dimensions ( ) const
pure virtual

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.

Implemented in lxgui::gui::sfml::material, lxgui::gui::sdl::material, and lxgui::gui::gl::material.

◆ get_canvas_uv()

vector2f lxgui::gui::material::get_canvas_uv ( const vector2f texture_uv,
bool  from_normalized 
) const

Returns normalized UV coordinates on the canvas, given local UV coordinates.

Parameters
texture_uvThe original UV coordinates, local to this texture
from_normalizedSet 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_local_uv()

vector2f lxgui::gui::material::get_local_uv ( const vector2f canvas_uv,
bool  as_normalized 
) const

Returns local UV coordinates on the texture, given canvas UV coordinates.

Parameters
canvas_uvThe canvas UV coordinates
as_normalizedSet 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()

virtual bounds2f lxgui::gui::material::get_rect ( ) const
pure virtual

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)

Implemented in lxgui::gui::sfml::material, lxgui::gui::sdl::material, and lxgui::gui::gl::material.

◆ is_in_atlas()

bool lxgui::gui::material::is_in_atlas ( ) const

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]

material& lxgui::gui::material::operator= ( const material )
delete

Non-copiable.

◆ operator=() [2/2]

material& lxgui::gui::material::operator= ( material &&  )
delete

Non-movable.

◆ uses_same_texture()

virtual bool lxgui::gui::material::uses_same_texture ( const material other) const
pure virtual

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

Implemented in lxgui::gui::sfml::material, lxgui::gui::sdl::material, and lxgui::gui::gl::material.

Member Data Documentation

◆ is_atlas_

bool lxgui::gui::material::is_atlas_ = false
protected

Definition at line 93 of file gui_material.hpp.


The documentation for this class was generated from the following files: