35#ifndef LIBTCOD_CONTEXT_H_
36#define LIBTCOD_CONTEXT_H_
182TCOD_NODISCARD
struct TCOD_Context* TCOD_context_new_(
void);
285 struct TCOD_Context* context,
float magnification,
int* __restrict columns,
int* __restrict rows);
303 int* __restrict width,
304 int* __restrict height);
319 struct TCOD_Context* __restrict context,
int* __restrict width,
int* __restrict height);
347 "TCOD_Context methods have been moved to tcod::Context,"
348 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
auto
363 "TCOD_Context methods have been moved to tcod::Context,"
364 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
void
378 "TCOD_Context methods have been moved to tcod::Context,"
379 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
void
393 "TCOD_Context methods have been moved to tcod::Context,"
394 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
auto
408 "TCOD_Context methods have been moved to tcod::Context,"
409 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
auto
421 "TCOD_Context methods have been moved to tcod::Context,"
422 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
auto
424 std::array<int, 2> out{xy[0], xy[1]};
436 "TCOD_Context methods have been moved to tcod::Context,"
437 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
auto
439 std::array<double, 2> out{xy[0], xy[1]};
456 "TCOD_Context methods have been moved to tcod::Context,"
457 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
void
472 "TCOD_Context methods have been moved to tcod::Context,"
473 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
void
487 "TCOD_Context methods have been moved to tcod::Context,"
488 " use `auto context = tcod::Context(params);` to make a tcod context for C++.")]]
void
511 if (magnification <= 0.0f) {
512 throw std::invalid_argument(
513 std::string(
"Magnification must be greater than zero. Got ") + std::to_string(magnification));
516 return tcod::Console{std::max(columns, min_columns), std::max(rows, min_rows)};
527 void* __restrict contextdata_;
532 void (*c_destructor_)(
struct TCOD_Context* __restrict self);
547 void (*c_pixel_to_tile_)(
struct TCOD_Context* __restrict self,
double* __restrict x,
double* __restrict y);
555 struct SDL_Window* (*c_get_sdl_window_)(
struct TCOD_Context* __restrict self);
559 struct SDL_Renderer* (*c_get_sdl_renderer_)(
struct TCOD_Context* __restrict self);
579 struct TCOD_Context* __restrict self,
float magnification,
int* __restrict columns,
int* __restrict rows);
591 int* __restrict width,
592 int* __restrict height);
607typedef std::unique_ptr<TCOD_Context, ContextDeleter> ContextPtr;
608typedef std::shared_ptr<TCOD_Context> ContextSharedPtr;
A managed libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console_types.hpp:80
Various console functions.
C++ types for console functions.
TCOD_ColorRGBA * TCOD_context_screen_capture_alloc(struct TCOD_Context *context, int *width, int *height)
Allocate and return a screen capture.
TCOD_Error TCOD_context_screen_capture(struct TCOD_Context *context, TCOD_ColorRGBA *out_pixels, int *width, int *height)
Fill out_pixels with a screen capture.
TCOD_Error TCOD_context_present(struct TCOD_Context *context, const struct TCOD_Console *console, const struct TCOD_ViewportOptions *viewport)
Present a console to the screen, using a rendering context.
int TCOD_context_get_renderer_type(struct TCOD_Context *context)
Return the TCOD_renderer_t renderer type for this context.
TCOD_Error TCOD_context_recommended_console_size(struct TCOD_Context *context, float magnification, int *columns, int *rows)
Set columns and rows to the recommended console size for this context.
TCOD_Error TCOD_context_screen_pixel_to_tile_i(struct TCOD_Context *context, int *x, int *y)
Convert the screen coordinates to integer tile coordinates for this context.
TCOD_Error TCOD_context_set_mouse_transform(struct TCOD_Context *context, const TCOD_MouseTransform *transform)
Manually set the pixel-to-tile mouse position transformation.
struct SDL_Window * TCOD_context_get_sdl_window(struct TCOD_Context *context)
Return a pointer the SDL_Window for this context if it uses one.
TCOD_Error TCOD_context_change_tileset(struct TCOD_Context *self, TCOD_Tileset *tileset)
Change the active tileset for this context.
struct SDL_Renderer * TCOD_context_get_sdl_renderer(struct TCOD_Context *context)
Return a pointer the SDL_Renderer for this context if it uses one.
void TCOD_context_delete(struct TCOD_Context *renderer)
Delete a rendering context.
TCOD_Error TCOD_context_convert_event_coordinates(struct TCOD_Context *context, union SDL_Event *event)
Convert the pixel coordinates of SDL mouse events to the tile coordinates of the current context.
TCOD_Error TCOD_context_save_screenshot(struct TCOD_Context *context, const char *filename)
Save the last presented console to a PNG file.
TCOD_Error TCOD_context_screen_pixel_to_tile_d(struct TCOD_Context *context, double *x, double *y)
Convert the screen coordinates to tile coordinates for this context.
Context viewport options.
TCOD_Error
An enum of libtcod error codes.
Definition error.h:48
Mouse state provided by the libtcod event system.
The libtcod namespace.
Definition bresenham.hpp:157
int check_throw_error(int error)
Check and throw error messages.
Definition error.hpp:57
A 4-channel RGBA color struct.
Definition color.h:92
A libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console.h:125
A rendering context for libtcod.
Definition context.h:340
void save_screenshot(const std::string &filepath)
Save a screenshot to filepath.
Definition context.h:489
void present(const TCOD_Console &console)
Present a console to the display.
Definition context.h:380
auto get_sdl_renderer() noexcept -> struct SDL_Renderer *
Return a non-owning pointer to the SDL_Renderer used by this context.
Definition context.h:410
auto pixel_to_tile_coordinates(const std::array< int, 2 > &xy) -> std::array< int, 2 >
Convert pixel coordinates to this contexts integer tile coordinates.
Definition context.h:423
void convert_event_coordinates(SDL_Event &event)
Convert the pixel coordinates of SDL mouse events to the tile coordinates of the current context.
Definition context.h:458
void save_screenshot(const char *filepath)
Save a screenshot to filepath.
Definition context.h:474
auto get_sdl_window() noexcept -> struct SDL_Window *
Return a non-owning pointer to the SDL_Window used by this context.
Definition context.h:395
auto pixel_to_tile_coordinates(const std::array< double, 2 > &xy) -> std::array< double, 2 >
Convert pixel coordinates to this contexts sub-tile coordinates.
Definition context.h:438
void present(const TCOD_Console &console, const TCOD_ViewportOptions &viewport)
Present a console to the display with the provided viewport options.
Definition context.h:365
int type
The TCOD_renderer_t value of this context.
Definition context.h:523
auto get_renderer_type() noexcept -> int
Return the TCOD_renderer_t value of this context which may be different than the one requested.
Definition context.h:349
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.
Definition context.h:508
A struct of parameters used to create a new context with TCOD_context_new.
Definition context.h:70
TCOD_Tileset * tileset
tileset is an optional pointer to a tileset object.
Definition context.h:107
int columns
columns and rows are the desired size of the terminal window.
Definition context.h:96
int window_x
window_x and window_y are the starting position of the window.
Definition context.h:84
int tcod_version
Compiled libtcod version for ABI compatiblity with older versions of libtcod.
Definition context.h:74
void(* cli_output)(void *userdata, const char *output)
If user attention is required for the given CLI parameters then cli_output will be called with cli_us...
Definition context.h:146
bool window_xy_defined
If this is false then window_x/window_y parameters of zero are assumed to be undefined and will be ch...
Definition context.h:155
int vsync
If vsync is true, then vertical sync will be enabled whenever possible.
Definition context.h:112
int pixel_width
pixel_width and pixel_height are the desired size of the window in pixels.
Definition context.h:89
const char * window_title
window_title will be the title of the opened window.
Definition context.h:126
const char *const * argv
argc and argv are optional CLI parameters.
Definition context.h:137
int renderer_type
renderer_type is one of the TCOD_renderer_t values.
Definition context.h:100
void * cli_userdata
This is passed to the userdata parameter of cli_output if called.
Definition context.h:150
TCOD_Console * console
A console to be used as a reference for the desired window size.
Definition context.h:164
int sdl_window_flags
sdl_window_flags is a bitfield of SDL_WindowFlags flags.
Definition context.h:120
int argc
The number of items in argv.
Definition context.h:130
A container for libtcod tileset graphics.
Definition tileset.h:62
Viewport options for the rendering context.
Definition context_viewport.h:48