Struct TCOD_Context¶
Defined in File context.h
Struct Documentation¶
-
struct TCOD_Context
A rendering context for libtcod.
New in version 1.16.
Public Functions
-
inline auto get_renderer_type() noexcept -> int¶
Return the TCOD_renderer_t value of this context which may be different than the one requested.
-
inline void present(const TCOD_Console &console, const TCOD_ViewportOptions &viewport)¶
Present a console to the display with the provided viewport options.
- Parameters
console – The TCOD_Console to render. This console can be any size.
viewport – The viewport options, which can change the way the console is scaled.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline void present(const TCOD_Console &console)¶
Present a console to the display.
- Parameters
console – The TCOD_Console to render. This console can be any size and will be stretched to fit the window.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline auto get_sdl_window() noexcept -> struct SDL_Window*¶
Return a non-owning pointer to the SDL_Window used by this context.
- Returns
A
struct SDL_Window*
pointer. This will be nullptr if this context does not use an SDL window.Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline auto get_sdl_renderer() noexcept -> struct SDL_Renderer*¶
Return a non-owning pointer to the SDL_Renderer used by this context.
- Returns
A
struct SDL_Renderer*
pointer. This will be nullptr if this context does not use SDL’s renderer.Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline auto pixel_to_tile_coordinates(const std::array<int, 2> &xy) -> std::array<int, 2>¶
Convert pixel coordinates to this contexts integer tile coordinates.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline auto pixel_to_tile_coordinates(const std::array<double, 2> &xy) -> std::array<double, 2>¶
Convert pixel coordinates to this contexts sub-tile coordinates.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline void convert_event_coordinates(SDL_Event &event)¶
Convert the pixel coordinates of SDL mouse events to the tile coordinates of the current context.
New in version 1.19.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.- Parameters
event – Any SDL_Event event. If the event type is compatible then its coordinates will be converted into tile coordinates.
-
inline void save_screenshot(const char *filepath)¶
Save a screenshot to
filepath
.- Parameters
filepath – The file path to save the screenshot at. If nullptr then a unique file name will be generated.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline void save_screenshot(const std::string &filepath)¶
Save a screenshot to
filepath
.- Parameters
filepath – The file path to save the screenshot at.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
-
inline auto new_console(int min_columns = 1, int min_rows = 1, float magnification = 1.0f) -> tcod::Console¶
Return a new console with a size automatically determined by the context.
- Parameters
min_columns – The minimum width to use for the new console, in tiles.
min_rows – The minimum height to use for the new console, in tiles.
magnification – Determines the apparent size of the tiles that will be rendered by a console created with the output values. A
magnification
larger then 1.0f will output smaller console parameters, which will show as larger tiles when presented. Only values larger than zero are allowed.
- Returns
Returns a tcod::Console of a dynamic size.
Deprecated since version 1.21: Replace
tcod::new_console(params)
withtcod::Context(params)
to get a C++ context.
Public Members
-
int type¶
The TCOD_renderer_t value of this context.
-
inline auto get_renderer_type() noexcept -> int¶