libtcoddocumentation

3.5. Miscellaneous utilities

Using a custom resolution for the fullscreen mode

This function allows you to force the use of a specific resolution in fullscreen mode.
The default resolution depends on the root console size and the font character size.

static void TCODSystem::forceFullscreenResolution(int width, int height)

void TCOD_sys_force_fullscreen_resolution(int width, int height)

sys_force_fullscreen_resolution(width, height)

static void TCODSystem::forceFullscreenResolution(int width, int height);

tcod.system.forceFullscreenResolution(width,height)

ParameterDescription
width,heightResolution to use when switching to fullscreen.
Will use the smallest available resolution so that :
resolution width >= width and resolution width >= root console width * font char width
resolution width >= height and resolution height >= root console height * font char height
Example:

TCODSystem::forceFullscreenResolution(800,600); // use 800x600 in fullscreen instead of 640x400
TCODConsole::initRoot(80,50,"",true);

TCOD_sys_force_fullscreen_resolution(800,600);
TCOD_console_init_root(80,50,"",true);

libtcod.sys_force_fullscreen_resolution(800,600)
libtcod.console_init_root(80,50,"",True)

tcod.system.forceFullscreenResolution(800,600) -- use 800x600 in fullscreen instead of 640x400
tcod.console.initRoot(80,50,"",true)


Get current resolution

You can get the current screen resolution with getCurrentResolution. You can use it for example to get the desktop resolution before initializing the root console.

static void TCODSystem::getCurrentResolution(int *width, int *height)

void TCOD_sys_get_current_resolution(int *width, int *height)

sys_get_current_resolution()

static void TCODSystem::getCurrentResolution(out int w, out int h);

ParameterDescription
width,heightcontains current resolution when the function returns

Get fullscreen offset

If the fullscreen resolution does not matches the console size in pixels, black borders are added. This function returns the position in pixels of the console top left corner in the screen.

static void TCODSystem::getFullscreenOffsets(int *offx, int *offy)

void TCOD_sys_get_fullscreen_offsets(int *offx, int *offy)

static void TCODSystem::getFullscreenOffsets(out int offx, out int offy);

ParameterDescription
offx,offycontains the position of the console on the screen when using fullscreen mode.

Get the font size

You can get the size of the characters in the font

static void TCODSystem::getCharSize(int *width, int *height)

void TCOD_sys_get_char_size(int *width, int *height)

sys_get_char_size()

static void TCODSystem::getCharSize(out int w, out int h);

ParameterDescription
width,heightcontains a character size when the function returns

Dynamically updating the font bitmap

You can dynamically change the bitmap of a character in the font. All cells using this ascii code will be updated at next flush call.

static void TCODSystem::updateChar(int asciiCode, int fontx, int fonty,const TCODImage *img,int x,int y)

void TCOD_sys_update_char(int asciiCode, int fontx, int fonty, TCOD_image_t img, int x, int y)

sys_update_char(asciiCode,fontx,fonty,img,x,y)

ParameterDescription
asciiCodeascii code corresponding to the character to update
fontx,fontycoordinate of the character in the bitmap font (in characters, not pixels)
imgimage containing the new character bitmap
x,yposition in pixels of the top-left corner of the character in the image

Dynamically change libtcod's internal renderer

As of 1.5.1, libtcod contains 3 different renderers :
* SDL : historic libtcod renderer. Should work and be pretty fast everywhere
* OpenGL : requires OpenGL compatible video card. Might be much faster or much slower than SDL, depending on the drivers
* GLSDL : requires OpenGL 1.4 compatible video card with GL_ARB_shader_objects extension. Blazing fast if you have the proper hardware and drivers.
This function switches the current renderer dynamically.

static void TCODSystem::setRenderer(TCOD_renderer_t renderer)

void TCOD_sys_set_renderer(TCOD_renderer_t renderer)

sys_set_renderer(renderer)

static void TCODSystem::setRenderer(TCODRendererType renderer);

ParameterDescription
rendererEither TCOD_RENDERER_GLSL, TCOD_RENDERER_OPENGL or TCOD_RENDERER_SDL

Get the current internal renderer

static TCOD_renderer_t TCODSystem::getRenderer()

TCOD_renderer_t TCOD_sys_get_renderer()

sys_get_renderer()

static TCODRendererType TCODSystem::getRenderer();