Use to draw a texture on the screen. More...
#include <gui_sprite.hpp>
Public Member Functions | |
| sprite (const manager *pManager, utils::refptr< material > pMat) | |
| Constructor. | |
| sprite (const manager *pManager, utils::refptr< material > pMat, float fWidth, float fHeight) | |
| Constructor. | |
| sprite (const manager *pManager, utils::refptr< material > pMat, float fU, float fV, float fWidth, float fHeight) | |
| Constructor. | |
| virtual | ~sprite () |
| Destructor. | |
| virtual void | render (float fX, float fY) const |
| Renders this sprite on the current render target. | |
| virtual void | render_ex (float fX, float fY, float fRot, float fHScale=1.0f, float fVScale=1.0f) const |
| Deforms this sprite and render it on the current render target. | |
| virtual void | render_2v (float fX1, float fY1, float fX3, float fY3) |
| Stretches this this sprite and render it on the current render target. | |
| virtual void | render_4v (float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, float fX4, float fY4) |
| Stretches this this sprite and render it on the current render target. | |
| virtual void | render_static () const |
| Renders this sprite with the same parameter than the last render call. | |
| virtual void | render_quads (const std::vector< std::array< vertex, 4 >> &lQuadsArray) const |
| Renders a set of quads using this sprite's material. | |
| virtual void | set_quad (const std::array< vertex, 4 > &lVertexArray) |
| Sets this sprite's internal quad. | |
| virtual void | set_color (const color &mColor, uint uiIndex=(uint)(-1)) |
| Changes the color of this sprite. | |
| virtual void | set_desaturated (bool bDesaturated) |
| Makes this sprite colorless. | |
| virtual void | set_blend_mode (blend_mode mBlendMode) |
| Sets the blending mode of this sprite. | |
| virtual void | set_hot_spot (const vector2f &mHotSpot) |
| Changes this sprite's center. | |
| virtual void | set_hot_spot (float fX, float fY) |
| Changes this sprite's center. | |
| virtual void | set_texture_rect (const std::array< float, 4 > &lTextureRect, bool bNormalized=false) |
| Changes this sprite's texture rectangle. | |
| virtual void | set_texture_rect (float fX1, float fY1, float fX3, float fY3, bool bNormalized=false) |
| Changes this sprite's texture rectangle. | |
| virtual void | set_texture_coords (const std::array< float, 8 > &lTextureCoords, bool bNormalized=false) |
| Changes this sprite's texture coordinates. | |
| virtual void | set_texture_coords (float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, float fX4, float fY4, bool bNormalized=false) |
| Changes this sprite's texture coordinates. | |
| virtual void | set_dimensions (float fWidth, float fHeight) |
| Changes this sprite's dimensions. | |
| virtual float | get_width () const |
| Returns this sprite's width. | |
| virtual float | get_height () const |
| Returns this sprite's height. | |
| virtual color | get_color () const |
| Returns this sprite's color. | |
| virtual blend_mode | get_blend_mode () const |
| Returns this sprite's blend mode. | |
| virtual std::array< float, 4 > | get_texture_rect () const |
| Returns this sprite's texture rectangle. | |
| virtual std::array< float, 8 > | get_texture_coords (bool bNormalized=false) const |
| Returns this sprite's texture coordinates. | |
Use to draw a texture on the screen.
This class is meant to simplify rendering of 2D elements. Everything can be done with a quad struct, but it's really not simple to use.
Thanks to this class, the only thing you have to do to acheive interesting effects is calling 2 or 3 functions and let the magic do the rest.
Definition at line 63 of file gui_sprite.hpp.
Constructor.
Definition at line 16 of file gui_sprite.cpp.
| gui::sprite::sprite | ( | const manager * | pManager, | |
| utils::refptr< material > | pMat, | |||
| float | fWidth, | |||
| float | fHeight | |||
| ) |
Constructor.
Definition at line 37 of file gui_sprite.cpp.
| gui::sprite::sprite | ( | const manager * | pManager, | |
| utils::refptr< material > | pMat, | |||
| float | fU, | |||
| float | fV, | |||
| float | fWidth, | |||
| float | fHeight | |||
| ) |
Constructor.
Definition at line 58 of file gui_sprite.cpp.
| gui::sprite::~sprite | ( | ) | [virtual] |
Destructor.
Definition at line 81 of file gui_sprite.cpp.
| blend_mode gui::sprite::get_blend_mode | ( | ) | const [virtual] |
Returns this sprite's blend mode.
Definition at line 300 of file gui_sprite.cpp.
| color gui::sprite::get_color | ( | ) | const [virtual] |
Returns this sprite's color.
Definition at line 295 of file gui_sprite.cpp.
| float gui::sprite::get_height | ( | ) | const [virtual] |
Returns this sprite's height.
Definition at line 290 of file gui_sprite.cpp.
| std::array< float, 8 > gui::sprite::get_texture_coords | ( | bool | bNormalized = false |
) | const [virtual] |
Returns this sprite's texture coordinates.
| bNormalized | 'true' to get coordinates converted to texture space |
Definition at line 310 of file gui_sprite.cpp.
| std::array< float, 4 > gui::sprite::get_texture_rect | ( | ) | const [virtual] |
Returns this sprite's texture rectangle.
Definition at line 305 of file gui_sprite.cpp.
| float gui::sprite::get_width | ( | ) | const [virtual] |
Returns this sprite's width.
Definition at line 285 of file gui_sprite.cpp.
| void gui::sprite::render | ( | float | fX, | |
| float | fY | |||
| ) | const [virtual] |
Renders this sprite on the current render target.
| fX | The horizontal position | |
| fY | The vertical position |
Definition at line 85 of file gui_sprite.cpp.
| void gui::sprite::render_2v | ( | float | fX1, | |
| float | fY1, | |||
| float | fX3, | |||
| float | fY3 | |||
| ) | [virtual] |
Stretches this this sprite and render it on the current render target.
| fX1 | The top-left corner horizontal position | |
| fY1 | The top-left corner vertical position | |
| fX3 | The bottom-right corner horizontal position | |
| fY3 | The bottom-right corner vertical position |
Definition at line 123 of file gui_sprite.cpp.
| void gui::sprite::render_4v | ( | float | fX1, | |
| float | fY1, | |||
| float | fX2, | |||
| float | fY2, | |||
| float | fX3, | |||
| float | fY3, | |||
| float | fX4, | |||
| float | fY4 | |||
| ) | [virtual] |
Stretches this this sprite and render it on the current render target.
| fX1 | The top-left corner horizontal position | |
| fY1 | The top-left corner vertical position | |
| fX2 | The top-right corner horizontal position | |
| fY2 | The top-right corner vertical position | |
| fX3 | The bottom-right corner horizontal position | |
| fY3 | The bottom-right corner vertical position | |
| fX4 | The bottom-left corner horizontal position | |
| fY4 | The bottom-left corner vertical position |
Definition at line 133 of file gui_sprite.cpp.
| void gui::sprite::render_ex | ( | float | fX, | |
| float | fY, | |||
| float | fRot, | |||
| float | fHScale = 1.0f, |
|||
| float | fVScale = 1.0f | |||
| ) | const [virtual] |
Deforms this sprite and render it on the current render target.
| fX | The horizontal position | |
| fY | The vertical position | |
| fRot | The rotation to apply (angle in radian) | |
| fHScale | The horizontal scale to apply | |
| fVScale | The vertical scale to apply |
Definition at line 95 of file gui_sprite.cpp.
| void gui::sprite::render_quads | ( | const std::vector< std::array< vertex, 4 >> & | lQuadsArray | ) | const [virtual] |
Renders a set of quads using this sprite's material.
| lQuadsArray | The set of quads you want to render. |
Definition at line 146 of file gui_sprite.cpp.
| void gui::sprite::render_static | ( | ) | const [virtual] |
Renders this sprite with the same parameter than the last render call.
Definition at line 151 of file gui_sprite.cpp.
| void gui::sprite::set_blend_mode | ( | blend_mode | mBlendMode | ) | [virtual] |
Sets the blending mode of this sprite.
| mBlendMode | The new blending mode |
Definition at line 178 of file gui_sprite.cpp.
| void gui::sprite::set_color | ( | const color & | mColor, | |
| uint | uiIndex = (uint)(-1) | |||
| ) | [virtual] |
| void gui::sprite::set_desaturated | ( | bool | bDesaturated | ) | [virtual] |
Makes this sprite colorless.
| bDesaturated | 'true' to desaturate the texture/color |
Definition at line 174 of file gui_sprite.cpp.
| void gui::sprite::set_dimensions | ( | float | fWidth, | |
| float | fHeight | |||
| ) | [virtual] |
Changes this sprite's dimensions.
| fWidth | The new width | |
| fHeight | The new height |
Definition at line 279 of file gui_sprite.cpp.
| void gui::sprite::set_hot_spot | ( | float | fX, | |
| float | fY | |||
| ) | [virtual] |
Changes this sprite's center.
| fX | The new center's horizontal position | |
| fY | The new center's vertical position |
Definition at line 188 of file gui_sprite.cpp.
| void gui::sprite::set_hot_spot | ( | const vector2f & | mHotSpot | ) | [virtual] |
Changes this sprite's center.
| mHotSpot | A 2D point containing the new center's position |
Definition at line 183 of file gui_sprite.cpp.
| void gui::sprite::set_quad | ( | const std::array< vertex, 4 > & | lVertexArray | ) | [virtual] |
Sets this sprite's internal quad.
| lVertexArray |
Definition at line 156 of file gui_sprite.cpp.
| void gui::sprite::set_texture_coords | ( | float | fX1, | |
| float | fY1, | |||
| float | fX2, | |||
| float | fY2, | |||
| float | fX3, | |||
| float | fY3, | |||
| float | fX4, | |||
| float | fY4, | |||
| bool | bNormalized = false | |||
| ) | [virtual] |
Changes this sprite's texture coordinates.
| fX1 | The sprites's top left horizontal position | |
| fY1 | The sprites's top left vertical position | |
| fX2 | The sprites's top right horizontal position | |
| fY2 | The sprites's top right vertical position | |
| fX3 | The sprites's bottom right horizontal position | |
| fY3 | The sprites's bottom right vertical position | |
| fX4 | The sprites's bottom left horizontal position | |
| fY4 | The sprites's bottom left vertical position | |
| bNormalized | 'true' if the coords are already converted to texture space |
Definition at line 257 of file gui_sprite.cpp.
| void gui::sprite::set_texture_coords | ( | const std::array< float, 8 > & | lTextureCoords, | |
| bool | bNormalized = false | |||
| ) | [virtual] |
Changes this sprite's texture coordinates.
| lTextureCoords | The new texture coordinates | |
| bNormalized | 'true' if the coords are already converted to texture space |
Definition at line 236 of file gui_sprite.cpp.
| void gui::sprite::set_texture_rect | ( | float | fX1, | |
| float | fY1, | |||
| float | fX3, | |||
| float | fY3, | |||
| bool | bNormalized = false | |||
| ) | [virtual] |
Changes this sprite's texture rectangle.
| fX1 | The rect's top left horizontal position | |
| fY1 | The rect's top left vertical position | |
| fX3 | The rect's bottom right horizontal position | |
| fY3 | The rect's bottom right vertical position | |
| bNormalized | 'true' if the coords are already clamped to [0, 1] |
Definition at line 215 of file gui_sprite.cpp.
| void gui::sprite::set_texture_rect | ( | const std::array< float, 4 > & | lTextureRect, | |
| bool | bNormalized = false | |||
| ) | [virtual] |
Changes this sprite's texture rectangle.
| lTextureRect | The new texture rect | |
| bNormalized | 'true' if the coords are already clamped to [0, 1] |
Definition at line 194 of file gui_sprite.cpp.
1.6.1