< index
< 3. System layer

=====================================
3.3 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.

C++ : static void TCODSystem::forceFullscreenResolution(int width, int height)
C   : void TCOD_sys_force_fullscreen_resolution(int width, int height)
Py  : sys_force_fullscreen_resolution(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 :

C++ : TCODSystem::forceFullscreenResolution(800,600); // use 800x600 in fullscreen instead of 640x400
      TCODConsole::initRoot(80,50,"",true); // 80x50 console with 8x8 char => 640x400 default resolution
C   : TCOD_sys_force_fullscreen_resolution(800,600); 
      TCOD_console_init_root(80,50,"",true);
Py  : libtcod.sys_force_fullscreen_resolution(800,600)
      libtcod.console_init_root(80,50,"",True)


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.

C++ : static void TCODSystem::getCurrentResolution(int *width, int *height)
C   : void TCOD_sys_get_current_resolution(int *width, int *height)
Py  : sys_get_current_resolution() # returns w,h

ParameterDescription
width, heightContain current resolution when the function returns.
Example :

C++ : int w,h;
      TCODSystem::getCurrentResolution(&w,&h); // get desktop resolution
      TCODConsole::initRoot(w/8,h/8,"",true); // sets the console size so that it fills the desktop with a 8x8 font
C   : TCOD_sys_get_current_resolution(&w,&h); 
      TCOD_console_init_root(w/8,h/8,"",true);
Py  : w,h=libtcod.sys_get_current_resolution() 
      libtcod.console_init_root(w/8,h/8,"",True)

insert a comment