|
libtcod
|
TCOD_Tileset loading and handling functions. More...
Classes | |
| struct | TCOD_TilesetObserver |
| struct | TCOD_Tileset |
| A container for libtcod tileset graphics. More... | |
Typedefs | |
| typedef struct TCOD_Tileset | TCOD_Tileset |
Functions | |
| TCOD_Tileset * | TCOD_tileset_new (int tile_width, int tile_height) |
| Create a new tile-set with the given tile size. | |
| void | TCOD_tileset_delete (TCOD_Tileset *tileset) |
| Delete a tile-set. | |
| TCOD_Tileset * | TCOD_tileset_load (const char *filename, int columns, int rows, int n, const int *charmap) |
| Load a PNG font as a tilesheet and return a TCOD_Tileset. | |
| TCOD_Tileset * | TCOD_tileset_load_mem (size_t buffer_length, const unsigned char *buffer, int columns, int rows, int n, const int *charmap) |
| Load a PNG font from memory and return a TCOD_Tileset. | |
| TCOD_Tileset * | TCOD_tileset_load_raw (int width, int height, const struct TCOD_ColorRGBA *pixels, int columns, int rows, int n, const int *charmap) |
| Load raw RGBA data and return a TCOD_Tileset. | |
| int | TCOD_tileset_assign_tile (struct TCOD_Tileset *tileset, int tile_id, int codepoint) |
| Assign a codepoint to an existing tile based on its tile ID. | |
| const struct TCOD_ColorRGBA * | TCOD_tileset_get_tile (const TCOD_Tileset *tileset, int codepoint) |
| Return a pointer to the tile for codepoint. | |
| struct TCOD_TilesetObserver * | TCOD_tileset_observer_new (struct TCOD_Tileset *tileset) |
| Return a new observer to this tileset. | |
| void | TCOD_tileset_observer_delete (struct TCOD_TilesetObserver *observer) |
| Delete an existing observer. | |
| void | TCOD_tileset_notify_tile_changed (TCOD_Tileset *tileset, int tile_id) |
| Called to notify any observers that a tile has been changed. | |
| TCOD_Error | TCOD_tileset_reserve (TCOD_Tileset *tileset, int desired) |
| Reserve memory for a specific amount of tiles. | |
| TCOD_Tileset * | TCOD_load_bdf (const char *path) |
| Load a BDF font from a file path. | |
| TCOD_Tileset * | TCOD_load_bdf_memory (int size, const unsigned char *buffer) |
| Load a BDF font from memory. | |
| TCOD_Error | TCOD_tileset_render_to_surface (const TCOD_Tileset *tileset, const TCOD_Console *console, TCOD_Console **cache, struct SDL_Surface **surface_out) |
| Render a console to a SDL_Surface with a software renderer. | |
TCOD_Tileset loading and handling functions.
| TCOD_Tileset * TCOD_load_bdf | ( | const char * | path | ) |
Load a BDF font from a file path.
For the best results, you should use a BDF font with a cell-based monospace alignment.
May return NULL on failure. See TCOD_get_error for the error message.
embed:rst:leading-asterisk .. versionadded:: 1.16
| TCOD_Tileset * TCOD_load_bdf_memory | ( | int | size, |
| const unsigned char * | buffer ) |
Load a BDF font from memory.
size is the byte length of buffer. buffer is the BDF data to load.
May return NULL on failure. See TCOD_get_error for the error message.
embed:rst:leading-asterisk .. versionadded:: 1.16
| int TCOD_tileset_assign_tile | ( | struct TCOD_Tileset * | tileset, |
| int | tile_id, | ||
| int | codepoint ) |
Assign a codepoint to an existing tile based on its tile ID.
| tileset | A TCOD_Tileset pointer, must not be NULL. |
| tile_id | The index of the tile. |
| codepoint | The Unicode codepoint to associate with tile_id. |
| void TCOD_tileset_delete | ( | TCOD_Tileset * | tileset | ) |
Delete a tile-set.
embed:rst:leading-asterisk .. versionadded:: 1.19
| const struct TCOD_ColorRGBA * TCOD_tileset_get_tile | ( | const TCOD_Tileset * | tileset, |
| int | codepoint ) |
Return a pointer to the tile for codepoint.
Returns NULL if no tile exists for codepoint.
| TCOD_Tileset * TCOD_tileset_load | ( | const char * | filename, |
| int | columns, | ||
| int | rows, | ||
| int | n, | ||
| const int * | charmap ) |
Load a PNG font as a tilesheet and return a TCOD_Tileset.
filename is the path to a PNG file.
columns and rows are the shape of the tileset in the image. The tile size will be derived from these parameters and the size of the image.
charmap[n] is an array of which codepoints to assign to which tiles. Tiles are assigned in row-major order. TCOD_CHARMAP_CP437 or TCOD_CHARMAP_TCOD could be used here.
embed:rst:leading-asterisk .. versionadded:: 1.19
| TCOD_Tileset * TCOD_tileset_load_mem | ( | size_t | buffer_length, |
| const unsigned char * | buffer, | ||
| int | columns, | ||
| int | rows, | ||
| int | n, | ||
| const int * | charmap ) |
Load a PNG font from memory and return a TCOD_Tileset.
buffer[buffer_length] is the PNG data to load.
The remaining parameters are the same as TCOD_tileset_load.
embed:rst:leading-asterisk .. versionadded:: 1.19
| TCOD_Tileset * TCOD_tileset_load_raw | ( | int | width, |
| int | height, | ||
| const struct TCOD_ColorRGBA * | pixels, | ||
| int | columns, | ||
| int | rows, | ||
| int | n, | ||
| const int * | charmap ) |
Load raw RGBA data and return a TCOD_Tileset.
pixels[width*height] is a row-major RGBA-ordered byte array.
The remaining parameters are the same as TCOD_tileset_load.
embed:rst:leading-asterisk .. versionadded:: 1.19
| TCOD_Tileset * TCOD_tileset_new | ( | int | tile_width, |
| int | tile_height ) |
Create a new tile-set with the given tile size.
embed:rst:leading-asterisk .. versionadded:: 1.19
| void TCOD_tileset_notify_tile_changed | ( | TCOD_Tileset * | tileset, |
| int | tile_id ) |
Called to notify any observers that a tile has been changed.
This may cause running atlases to update or mark cache consoles as dirty.
For internal use.
| void TCOD_tileset_observer_delete | ( | struct TCOD_TilesetObserver * | observer | ) |
Delete an existing observer.
Will call this observers on_observer_delete callback.
For internal use.
| struct TCOD_TilesetObserver * TCOD_tileset_observer_new | ( | struct TCOD_Tileset * | tileset | ) |
Return a new observer to this tileset.
For internal use.
| TCOD_Error TCOD_tileset_render_to_surface | ( | const TCOD_Tileset * | tileset, |
| const TCOD_Console * | console, | ||
| TCOD_Console ** | cache, | ||
| struct SDL_Surface ** | surface_out ) |
Render a console to a SDL_Surface with a software renderer.
tileset is the tiles to render with, must not be NULL.
console is the console to render, must not be NULL.
cache is an optional pointer to a consoled used as a cache. The console at *cache will be created or modified. The cache will be used to skip drawing already drawn tiles on any subsequent calls.
surface_out is a pointer to where to put the surface will be managed. The surface at *surface_out will be created or modified and will change to match the size of console and tileset. The pixel format will be SDL_PIXELFORMAT_RGBA32.
Returns a negative value on error, see TCOD_get_error.
embed:rst:leading-asterisk .. versionadded:: 1.16
| TCOD_Error TCOD_tileset_reserve | ( | TCOD_Tileset * | tileset, |
| int | desired ) |
Reserve memory for a specific amount of tiles.
For internal use.