Console Rendering Extension tcod.render#

Handles the rendering of libtcod’s tilesets.

Using this module you can render a console to an SDL Texture directly, letting you have full control over how consoles are displayed. This includes rendering multiple tilesets in a single frame and rendering consoles on top of each other.


tileset = tcod.tileset.load_tilesheet("dejavu16x16_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD)
console = tcod.console.Console(20, 8)
console.print(0, 0, "Hello World")
sdl_window =
    console.width * tileset.tile_width,
    console.height * tileset.tile_height,
sdl_renderer = tcod.sdl.render.new_renderer(sdl_window, target_textures=True)
atlas = tcod.render.SDLTilesetAtlas(sdl_renderer, tileset)
console_render = tcod.render.SDLConsoleRender(atlas)
while True:
    for event in tcod.event.wait():
        if isinstance(event, tcod.event.Quit):
            raise SystemExit()

New in version 13.4.

class tcod.render.SDLConsoleRender(atlas: SDLTilesetAtlas)[source]#

Holds an internal cache console and texture which are used to optimized console rendering.

render(console: Console) Texture[source]#

Render a console to a cached Texture and then return the Texture.

You should not draw onto the returned Texture as only changed parts of it will be updated on the next call.

This function requires the SDL renderer to have target texture support. It will also change the SDL target texture for the duration of the call.

atlas: Final[SDLTilesetAtlas]#

The SDLTilesetAtlas used to create this SDLConsoleRender.

New in version 13.7.

class tcod.render.SDLTilesetAtlas(renderer: Renderer, tileset: Tileset)[source]#

Prepares a tileset for rendering using SDL.

tileset: Final[Tileset]#

The tileset used to create this SDLTilesetAtlas.