A Render_sprite works by allowing its derived classes to render themselves pixel-by-pixel onto an SDL_Surface☛.
Then it converts the rendered surface into a Texture, which it caches.
The constructor of the derived class should pass the required dimensions to the Render_sprite constructor. Then, in its own constructor, use fill_surface(), fill_rectangle(), and set_pixel() to paint the desired sprite image to the surface. Or for direct access to the underlying SDL_Surface☛, use raw_surface().
Definition at line 104 of file ge211_sprites.hxx.
Inheritance diagram for Render_sprite:
Collaboration diagram for Render_sprite:Protected Member Functions | |
| Render_sprite (Dims< int >) | |
| Constructs a Render_sprite with the given pixel dimensions. More... | |
| bool | can_paint () const |
| Returns whether we can paint to this Render_sprite. More... | |
| void | fill_surface (Color) |
| Fills the whole surface with the given color. More... | |
| void | fill_rectangle (Rect< int >, Color) |
| Fills the given rectangle in the given color. More... | |
| void | set_pixel (Posn< int >, Color) |
| Sets one pixel to the given color. More... | |
| Borrowed< SDL_Surface > | raw_surface () |
Gains access to the underlying SDL_Surface☛. More... | |
|
explicitprotected |
Constructs a Render_sprite with the given pixel dimensions.
Definition at line 66 of file ge211_sprites.cxx.
|
protected |
Returns whether we can paint to this Render_sprite.
If this sprite has already been rendered to the screen then this function returns false. When the result is false, then calling any of fill_surface(), fill_rectangle(), set_pixel(), or raw_surface() will throw an exceptions::Late_paint_error exception.
Fills the given rectangle in the given color.
Typically this will only be called from a derived class's constructor.
Throws exceptions::Late_paint_error if !can_paint().
Definition at line 81 of file ge211_sprites.cxx.
|
protected |
Fills the whole surface with the given color.
Typically this will only be called from a derived class's constructor.
Throws exceptions::Late_paint_error if !can_paint().
Definition at line 75 of file ge211_sprites.cxx.
|
protected |
Gains access to the underlying SDL_Surface☛.
Typically this will only be called from a derived class's constructor. Never returns null.
Throws exceptions::Late_paint_error if !can_paint().
Definition at line 70 of file ge211_sprites.cxx.
Sets one pixel to the given color.
Typically this will only be called from a derived class's constructor.
Throws exceptions::Late_paint_error if !can_paint().
Definition at line 86 of file ge211_sprites.cxx.