Stores either a surface or texture which can be drawn on screen by providing a renderer to render().
More...
#include <Drawable.hpp>
|
| Drawable () |
| Height of mask. More...
|
|
| Drawable (Renderer *renderer, SDL_Surface *surf, const unsigned int width, const unsigned int height) |
| Create a Drawable from a surface. More...
|
|
| Drawable (Renderer *renderer, SDL_Texture *tex, const unsigned int width, const unsigned int height) |
| Create a Drawable from a texture. More...
|
|
ImageData | getImageData () |
| Returns the ImageData for the currently stored image. More...
|
|
void | setColour (const Colour &colour) |
| Set colour to tint Drawable with when rendered. More...
|
|
void | setMask (const int x, const int y, const unsigned int width, const unsigned int height) |
| Set the mask (area to draw) More...
|
|
void | render (const int x, const int y, const unsigned int width=0, const unsigned int height=0) |
| Render the Drawable on screen at the given coordinates. More...
|
|
bool | convertToTexture () |
| Convert the contained surface to a texture. Has no effect if the Drawable does not contain a surface. More...
|
|
Type | type () |
| Returns the type of the data stored. More...
|
|
int | width () |
| Returns the width of the Drawable in pixels. More...
|
|
int | height () |
| Returns the height of the Drawable in pixels. More...
|
|
| ~Drawable () |
| Destructor ensures contained data is deleted appropriately.
|
|
Stores either a surface or texture which can be drawn on screen by providing a renderer to render().
- Note
- This class is not thread-safe by itself.
-
All instances of this should be deleted before deleting the main renderer.
◆ Type
Type of raw data stored.
Enumerator |
---|
None | Doesn't store any data that can be rendered
|
Surface | Currently stores a SDL 'surface'
|
Texture | Currently stores a SDL 'texture'
|
◆ Drawable() [1/3]
Aether::Drawable::Drawable |
( |
| ) |
|
Height of mask.
Default constructor. Initializes with no data.
- Note
- This is effectively useless: it's here for default allocations.
◆ Drawable() [2/3]
Aether::Drawable::Drawable |
( |
Renderer * |
renderer, |
|
|
SDL_Surface * |
surf, |
|
|
const unsigned int |
width, |
|
|
const unsigned int |
height |
|
) |
| |
Create a Drawable from a surface.
- Parameters
-
renderer | Renderer to draw/manipulate Drawable with |
surf | Surface to instantiate with |
width | Width of given surface (in pixels) |
height | Height of given surface (in pixels) |
◆ Drawable() [3/3]
Aether::Drawable::Drawable |
( |
Renderer * |
renderer, |
|
|
SDL_Texture * |
tex, |
|
|
const unsigned int |
width, |
|
|
const unsigned int |
height |
|
) |
| |
Create a Drawable from a texture.
- Parameters
-
renderer | Renderer to draw/manipulate Drawable with |
tex | Texture to instantiate with |
width | Width of given texture (in pixels) |
height | Height of given texture (in pixels) |
◆ convertToTexture()
bool Aether::Drawable::convertToTexture |
( |
| ) |
|
Convert the contained surface to a texture. Has no effect if the Drawable does not contain a surface.
- Note
- This should be called by the same thread that instantiated the renderer!
- Returns
- true if successful/not a surface, false if conversion failed
◆ getImageData()
Returns the ImageData for the currently stored image.
- Returns
- ImageData for the currently stored image.
◆ height()
int Aether::Drawable::height |
( |
| ) |
|
Returns the height of the Drawable in pixels.
- Returns
- Height of Drawable in pixels, 0 if no data stored
◆ render()
void Aether::Drawable::render |
( |
const int |
x, |
|
|
const int |
y, |
|
|
const unsigned int |
width = 0 , |
|
|
const unsigned int |
height = 0 |
|
) |
| |
Render the Drawable on screen at the given coordinates.
- Parameters
-
x | X coordinate (top-left) |
y | Y coordinate (top-left) |
width | Width to render at (optional, defaults to Drawable size) |
height | Height to render at (optional, defaults to Drawable size) |
◆ setColour()
void Aether::Drawable::setColour |
( |
const Colour & |
colour | ) |
|
Set colour to tint Drawable with when rendered.
- Parameters
-
◆ setMask()
void Aether::Drawable::setMask |
( |
const int |
x, |
|
|
const int |
y, |
|
|
const unsigned int |
width, |
|
|
const unsigned int |
height |
|
) |
| |
Set the mask (area to draw)
- Parameters
-
x | X coordinate of mask (top-left) |
y | Y coordinate of mask (top-left) |
width | Width of mask |
height | Height of mask |
◆ type()
Type Aether::Drawable::type |
( |
| ) |
|
Returns the type of the data stored.
- Returns
- Type of raw data stored (see Type)
◆ width()
int Aether::Drawable::width |
( |
| ) |
|
Returns the width of the Drawable in pixels.
- Returns
- Width of Drawable in pixels, 0 if no data stored
The documentation for this class was generated from the following file: