A class that holds rendering data. More...
#include <gui_gl_material.hpp>
Classes | |
struct | color_data |
struct | texture_data |
Public Types | |
enum | wrap { REPEAT, CLAMP } |
enum | filter { NONE, LINEAR } |
enum | type { TYPE_TEXTURE, TYPE_COLOR } |
Public Member Functions | |
material (uint uiWidth, uint uiHeight, wrap mWrap=REPEAT, filter mFilter=NONE, bool bGPUOnly=false) | |
Constructor for textures. | |
material (const color &mColor) | |
Constructor for plain colors. | |
~material () | |
Destructor. | |
type | get_type () const |
Returns the type of this texture (texture or color). | |
float | get_width () const |
Returns the width of the underlying texture (if any). | |
float | get_height () const |
Returns the height of the underlying texture (if any). | |
float | get_real_width () const |
Returns the physical width of the underlying texture (if any). | |
float | get_real_height () const |
Returns the physical height of the underlying texture (if any). | |
bool | set_dimensions (uint uiWidth, uint uiHeight) |
Resizes this texture. | |
color | get_color () const |
Returns the plain color of this texture. | |
void | premultiply_alpha () |
Premultiplies the texture by alpha component. | |
void | set_wrap (wrap mWrap) |
Sets the wrap mode of this texture. | |
void | set_filter (filter mFilter) |
Sets the filter mode of this texture. | |
void | bind () const |
Sets this material as the active one. | |
const std::vector< ub32color > & | get_data () const |
Returns the cached texture data (read only). | |
std::vector< ub32color > & | get_data () |
Returns the cached texture data (read and write). | |
void | set_pixel (uint x, uint y, const ub32color &mColor) |
Sets the color of one pixel. | |
const ub32color & | get_pixel (uint x, uint y) const |
Returns the color of one pixel (read only). | |
ub32color & | get_pixel (uint x, uint y) |
Returns the color of one pixel. | |
void | update_texture () |
Updates the texture that is in GPU memory. | |
void | clear_cache_data_ () |
Removes the cached texture data (in CPU memory). | |
uint | get_handle_ () |
Returns the OpenGL texture handle. | |
Static Public Member Functions | |
static void | check_availability () |
Checks if the machine is capable of using some features. |
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 25 of file gui_gl_material.hpp.
Definition at line 35 of file gui_gl_material.hpp.
Definition at line 41 of file gui_gl_material.hpp.
Definition at line 29 of file gui_gl_material.hpp.
gui::gl::material::material | ( | uint | uiWidth, | |
uint | uiHeight, | |||
wrap | mWrap = REPEAT , |
|||
filter | mFilter = NONE , |
|||
bool | bGPUOnly = false | |||
) |
Constructor for textures.
uiWidth | The requested texture width | |
uiHeight | The requested texture height | |
mWrap | How to adjust texture coordinates that are outside the [0,1] range | |
mFilter | Use texture filtering or not (see set_filter()) bGPUOnly If 'false', a copy of the texture is kept in CPU memory (RAM). Else the texture only resides in GPU memory (used by render_target). |
Definition at line 15 of file gui_gl_material.cpp.
gui::gl::material::material | ( | const color & | mColor | ) |
Constructor for plain colors.
mColor | The plain color to use |
Definition at line 84 of file gui_gl_material.cpp.
gui::gl::material::~material | ( | ) | [virtual] |
void gui::gl::material::bind | ( | ) | const |
Sets this material as the active one.
Definition at line 155 of file gui_gl_material.cpp.
void gui::gl::material::check_availability | ( | ) | [static] |
Checks if the machine is capable of using some features.
Definition at line 350 of file gui_gl_material.cpp.
void gui::gl::material::clear_cache_data_ | ( | ) |
Removes the cached texture data (in CPU memory).
Definition at line 340 of file gui_gl_material.cpp.
color gui::gl::material::get_color | ( | ) | const |
std::vector< ub32color > & gui::gl::material::get_data | ( | ) |
Returns the cached texture data (read and write).
Definition at line 165 of file gui_gl_material.cpp.
const std::vector< ub32color > & gui::gl::material::get_data | ( | ) | const |
Returns the cached texture data (read only).
Definition at line 160 of file gui_gl_material.cpp.
uint gui::gl::material::get_handle_ | ( | ) |
Returns the OpenGL texture handle.
Definition at line 345 of file gui_gl_material.cpp.
float gui::gl::material::get_height | ( | ) | const [virtual] |
Returns the height of the underlying texture (if any).
Implements gui::material.
Definition at line 211 of file gui_gl_material.cpp.
ub32color & gui::gl::material::get_pixel | ( | uint | x, | |
uint | y | |||
) |
Returns the color of one pixel.
x | The coordinate of the pixel in the texture | |
y | The coordinate of the pixel in the texture |
Definition at line 180 of file gui_gl_material.cpp.
const ub32color & gui::gl::material::get_pixel | ( | uint | x, | |
uint | y | |||
) | const |
float gui::gl::material::get_real_height | ( | ) | const [virtual] |
Returns the physical height of the underlying texture (if any).
Implements gui::material.
Definition at line 237 of file gui_gl_material.cpp.
float gui::gl::material::get_real_width | ( | ) | const [virtual] |
Returns the physical width of the underlying texture (if any).
Implements gui::material.
Definition at line 224 of file gui_gl_material.cpp.
material::type gui::gl::material::get_type | ( | ) | const |
float gui::gl::material::get_width | ( | ) | const [virtual] |
Returns the width of the underlying texture (if any).
Implements gui::material.
Definition at line 198 of file gui_gl_material.cpp.
void gui::gl::material::premultiply_alpha | ( | ) |
Premultiplies the texture by alpha component.
Definition at line 185 of file gui_gl_material.cpp.
bool gui::gl::material::set_dimensions | ( | uint | uiWidth, | |
uint | uiHeight | |||
) |
void gui::gl::material::set_filter | ( | filter | mFilter | ) |
Sets the filter mode of this texture.
mFilter | Use texture filtering or not |
Definition at line 133 of file gui_gl_material.cpp.
void gui::gl::material::set_pixel | ( | uint | x, | |
uint | y, | |||
const ub32color & | mColor | |||
) |
Sets the color of one pixel.
x | The coordinate of the pixel in the texture | |
y | The coordinate of the pixel in the texture | |
mColor | The new color of the pixel |
Definition at line 170 of file gui_gl_material.cpp.
void gui::gl::material::set_wrap | ( | wrap | mWrap | ) |
Sets the wrap mode of this texture.
mWrap | How to adjust texture coordinates that are outside the [0,1] range |
Definition at line 111 of file gui_gl_material.cpp.
void gui::gl::material::update_texture | ( | ) |
Updates the texture that is in GPU memory.
Definition at line 327 of file gui_gl_material.cpp.