|
libtcod
|
Low level SDL2 tileset rendering. More...
#include <SDL3/SDL_properties.h>#include <stdbool.h>#include "config.h"#include "console.h"#include "context.h"#include "error.h"#include "mouse.h"#include "tileset.h"Go to the source code of this file.
Classes | |
| struct | TCOD_TilesetAtlasSDL2 |
| An SDL tileset atlas. More... | |
| struct | TCOD_RendererSDL2 |
| The renderer data for an SDL rendering context. More... | |
Typedefs | |
| typedef struct TCOD_TilesetAtlasSDL2 | TCOD_TilesetAtlasSDL2 |
| An SDL tileset atlas. | |
Functions | |
| struct TCOD_Context * | TCOD_renderer_init_sdl2 (int x, int y, int width, int height, const char *title, int window_flags, int vsync, struct TCOD_Tileset *tileset) |
| Return a libtcod rendering context using an SDL renderer. | |
| TCOD_Context * | TCOD_renderer_init_sdl3 (SDL_PropertiesID window_props, SDL_PropertiesID renderer_props, struct TCOD_Tileset *tileset) |
| Return a libtcod rendering context using SDL3. | |
| struct TCOD_TilesetAtlasSDL2 * | TCOD_sdl2_atlas_new (struct SDL_Renderer *renderer, struct TCOD_Tileset *tileset) |
| Return a new SDL atlas created from a tileset for an SDL3 renderer. | |
| void | TCOD_sdl2_atlas_delete (struct TCOD_TilesetAtlasSDL2 *atlas) |
| Delete an SDL tileset atlas. | |
| TCOD_Error | TCOD_sdl2_render_texture_setup (const struct TCOD_TilesetAtlasSDL2 *atlas, const struct TCOD_Console *console, struct TCOD_Console **cache, struct SDL_Texture **target) |
| Setup a cache and target texture for rendering. | |
| TCOD_Error | TCOD_sdl2_render_texture (const struct TCOD_TilesetAtlasSDL2 *atlas, const struct TCOD_Console *console, struct TCOD_Console *cache, struct SDL_Texture *target) |
| Render a console onto a managed target texture. | |
Low level SDL2 tileset rendering.
| typedef struct TCOD_TilesetAtlasSDL2 TCOD_TilesetAtlasSDL2 |
An SDL tileset atlas.
This prepares a tileset for use with SDL.
This works for SDL3 despite the name.
embed:rst:leading-asterisk .. versionadded:: 1.16
| struct TCOD_Context * TCOD_renderer_init_sdl2 | ( | int | x, |
| int | y, | ||
| int | width, | ||
| int | height, | ||
| const char * | title, | ||
| int | window_flags, | ||
| int | vsync, | ||
| struct TCOD_Tileset * | tileset ) |
Return a libtcod rendering context using an SDL renderer.
Despite the name this returns a context for SDL3.
| x | Window X position, if unsure then use SDL_WINDOWPOS_UNDEFINED |
| y | Window Y position, if unsure then use SDL_WINDOWPOS_UNDEFINED |
| width | Window width in pixels |
| height | Window height in pixels |
| title | Window title text |
| window_flags | SDL window flags, see SDL_WindowFlags |
| vsync | Enables VSync |
| tileset | The tileset to use for this context. |
| TCOD_Context * TCOD_renderer_init_sdl3 | ( | SDL_PropertiesID | window_props, |
| SDL_PropertiesID | renderer_props, | ||
| struct TCOD_Tileset * | tileset ) |
Return a libtcod rendering context using SDL3.
| window_props | The SDL3 window properties. See SDL_CreateWindowWithProperties. |
| renderer_props | The SDL3 rendering properties. See SDL_CreateRendererWithProperties. |
| tileset | The tileset to use for this renderer. |
| struct TCOD_TilesetAtlasSDL2 * TCOD_sdl2_atlas_new | ( | struct SDL_Renderer * | renderer, |
| struct TCOD_Tileset * | tileset ) |
Return a new SDL atlas created from a tileset for an SDL3 renderer.
You may delete the tileset if you no longer have use for it.
Will return NULL on an error, you can check the error with TCOD_get_error.
| TCOD_Error TCOD_sdl2_render_texture | ( | const struct TCOD_TilesetAtlasSDL2 * | atlas, |
| const struct TCOD_Console * | console, | ||
| struct TCOD_Console * | cache, | ||
| struct SDL_Texture * | target ) |
Render a console onto a managed target texture.
This function assumes that cache and target are valid. You can use TCOD_sdl2_render_texture_setup to automatically prepare these objects for use with this function.
atlas is an SDL atlas created with TCOD_sdl2_atlas_new. The renderer used to make this atlas must support SDL_RENDERER_TARGETTEXTURE, unless target is NULL.
console is a non-NULL pointer to the libtcod console you want to render.
cache can be NULL, or point to a console the same size as console.
target can be NULL, or be pointer an SDL texture used as the output. If target is not NULL then it should be the size of the console times the size of the individual tiles to fit the entire output.
If target is NULL then the current render target is used instead, the drawn area will not be scaled to fit the render target.
If SDL3 ever provides a SDL_EVENT_RENDER_TARGETS_RESET event then the console at cache must be cleared, or else the next render will only partially update the texture of target.
Returns a negative value on an error, check TCOD_get_error.
embed:rst:leading-asterisk .. versionadded:: 1.16
| TCOD_Error TCOD_sdl2_render_texture_setup | ( | const struct TCOD_TilesetAtlasSDL2 * | atlas, |
| const struct TCOD_Console * | console, | ||
| struct TCOD_Console ** | cache, | ||
| struct SDL_Texture ** | target ) |
Setup a cache and target texture for rendering.
atlas is an SDL atlas created with TCOD_sdl2_atlas_new. The renderer used to make this atlas must support SDL_RENDERER_TARGETTEXTURE.
console is a non-NULL pointer to the libtcod console you want to render.
cache can be NULL, or be pointer to a console pointer. If *cache is NULL then a console will be created. If *cache isn't NULL then the console pointed to might be deleted or recreated if it does not match the size of console.
target must be a pointer to where you want the output texture to be placed. The texture at *target may be deleted or recreated. When this function is successful then the texture at *target will be non-NULL and will be exactly fitted to the size of console and the tile size of atlas.
If SDL ever provides a SDL_EVENT_RENDER_TARGETS_RESET event then the console at *cache must be deleted and set to NULL, or else the next render will only partially update the texture at *target.
Returns a negative value on an error, check TCOD_get_error.
embed:rst:leading-asterisk .. versionadded:: 1.16