libtcod
Loading...
Searching...
No Matches
console_init.h File Reference

Deprecated root console initialization. More...

#include "config.h"
#include "console.h"
#include "console_types.h"
#include "context.h"
#include "error.h"
#include "tileset.h"

Go to the source code of this file.

Namespaces

namespace  tcod
 The libtcod namespace.

Functions

TCOD_Error TCOD_console_init_root (int w, int h, const char *title, bool fullscreen, TCOD_renderer_t renderer)
 Initialize the libtcod graphical engine.
void TCOD_console_set_window_title (const char *title)
 Change the title string of the active window.
void TCOD_console_set_fullscreen (bool fullscreen)
 Set the display to be full-screen or windowed.
bool TCOD_console_is_fullscreen (void)
 Return true if the display is full-screen.
bool TCOD_console_has_mouse_focus (void)
 Return true if the window has mouse focus.
bool TCOD_console_is_active (void)
 Return true if the window has keyboard focus.
bool TCOD_console_is_window_closed (void)
 Return true if the window is closing.
struct SDL_Window * TCOD_sys_get_sdl_window (void)
 Return an SDL_Window pointer if one is in use, returns NULL otherwise.
struct SDL_Renderer * TCOD_sys_get_sdl_renderer (void)
 Return an SDL_Renderer pointer if one is in use, returns NULL otherwise.
int TCOD_sys_accumulate_console (const TCOD_Console *console)
 Render a console over the display.
TCOD_ContextTCOD_sys_get_internal_context (void)
 Return the context being used internally by the old API.
TCOD_ConsoleTCOD_sys_get_internal_console (void)
 Return a pointer to the "root console" used internally by the old API.
void TCOD_quit (void)
 Shutdown libtcod.
void tcod::console::init_root (int w, int h, const std::string &title, bool fullscreen, TCOD_renderer_t renderer)
void tcod::console::init_root (int w, int h, const std::string &title, bool fullscreen, TCOD_renderer_t renderer, bool vsync)

Detailed Description

Deprecated root console initialization.

Function Documentation

◆ TCOD_console_init_root()

TCOD_Error TCOD_console_init_root ( int w,
int h,
const char * title,
bool fullscreen,
TCOD_renderer_t renderer )

Initialize the libtcod graphical engine.

Parameters
wThe width in tiles.
hThe height in tiles.
titleThe title for the window.
fullscreenFullscreen option.
rendererWhich renderer to use when rendering the console.

You may want to call TCOD_console_set_custom_font BEFORE calling this function. By default this function loads libtcod's terminal.png image from the working directory.

Afterwards TCOD_quit must be called before the program exits.

Returns 0 on success, or -1 on an error, you can check the error with TCOD_sys_get_error()

renderer and vsync settings can be overridden by the TCOD_RENDERER or TCOD_VSYNC environment variables.

Valid case-sensitive options for TCOD_RENDERER are:

  • sdl
  • opengl
  • glsl
  • sdl2
  • opengl2

Valid options for TCOD_VSYNC are 0 or 1.

embed:rst:leading-asterisk 
*  .. versionchanged:: 1.12
*      Now returns -1 on error instead of crashing.
*
*  .. versionchanged:: 1.13
*      Added the `TCOD_RENDERER` and `TCOD_VSYNC` overrides.
*  

◆ TCOD_console_is_active()

bool TCOD_console_is_active ( void )

Return true if the window has keyboard focus.

embed:rst:leading-asterisk
*  .. versionchanged: 1.7
*      This function was previously broken.  It now keeps track of keyboard
*      focus.
*  

◆ TCOD_console_set_fullscreen()

void TCOD_console_set_fullscreen ( bool fullscreen)

Set the display to be full-screen or windowed.

Parameters
fullscreenIf true the display will go full-screen.

◆ TCOD_console_set_window_title()

void TCOD_console_set_window_title ( const char * title)

Change the title string of the active window.

Parameters
titleA utf8 string.

◆ TCOD_quit()

void TCOD_quit ( void )

Shutdown libtcod.

This must be called before your program exits.

embed:rst:leading-asterisk 
.. versionadded:: 1.8

◆ TCOD_sys_accumulate_console()

int TCOD_sys_accumulate_console ( const TCOD_Console * console)

Render a console over the display.

embed:rst:leading-asterisk 
*  `console` can be any size, the active render will try to scale it to fit
*  the screen.
*
*  The function will only work for the SDL2/OPENGL2 renderers.
*
*  Unlike TCOD_console_flush this will not present the display.
*  You will need to do that manually, likely with the SDL API.
*
*  Returns 0 on success, or a negative number on a failure such as the
*  incorrect renderer being active.
*
*  .. versionadded:: 1.11
*
*  .. seealso::
*      TCOD_sys_get_sdl_window TCOD_sys_get_sdl_renderer
*  

◆ TCOD_sys_get_internal_console()

TCOD_Console * TCOD_sys_get_internal_console ( void )

Return a pointer to the "root console" used internally by the old API.

This is useful for functions which take a console parameter but won't accept NULL.

Returns
A pointer to TCOD_Console, or NULL if it doesn't exist.
embed:rst:leading-asterisk 
.. versionadded:: 1.19

◆ TCOD_sys_get_internal_context()

TCOD_Context * TCOD_sys_get_internal_context ( void )

Return the context being used internally by the old API.

Returns
A TCOD_Context pointer, or NULL if the global internals were not initialzed.

This function can be useful to progressively upgrade older code to use the newer API.

embed:rst:leading-asterisk 
.. versionadded:: 1.19

◆ TCOD_sys_get_sdl_renderer()

struct SDL_Renderer * TCOD_sys_get_sdl_renderer ( void )

Return an SDL_Renderer pointer if one is in use, returns NULL otherwise.

embed:rst:leading-asterisk 
*  .. versionadded:: 1.11
*  

◆ TCOD_sys_get_sdl_window()

struct SDL_Window * TCOD_sys_get_sdl_window ( void )

Return an SDL_Window pointer if one is in use, returns NULL otherwise.

embed:rst:leading-asterisk 
*  .. versionadded:: 1.11
*