Display
Display and window management routines.
Header: #include <asw/modules/display.h>Namespace: asw::display
Variables
renderer
extern asw::Renderer* renderer;The SDL renderer for the display module.
window
extern asw::Window* window;The SDL window for the display module.
Functions
set_title
void set_title(const std::string& title);Set the title of the window.
set_icon
void set_icon(const std::string& path);Set the icon to display on the window. Silently fails if the file does not exist.
set_fullscreen
void set_fullscreen(bool fullscreen);Set the window to fullscreen or windowed mode.
set_resolution
void set_resolution(int w, int h);Set the resolution of the window.
set_resizable
void set_resizable(bool resizable);Set whether the window is resizable.
get_size
asw::Vec2<int> get_size();Returns the actual size of the window.
get_logical_size
asw::Vec2<int> get_logical_size();Returns the logical size of the window. This may differ from the actual size if scaling is enabled.
get_scale
asw::Vec2<float> get_scale();Returns the scale of the window (logical size / actual size).
set_render_target
void set_render_target(const asw::Texture& texture);Set the render target to a texture.
reset_render_target
void reset_render_target();Reset the render target back to the default (the window).
clear
void clear();
void clear(const asw::Color& color);Clear the window. Optionally specify a color to clear to.
present
void present();Present the rendered frame to the window.
set_blend_mode
void set_blend_mode(asw::BlendMode mode);Set the blend mode of the renderer.
Example
asw::display::set_title("My Game");
asw::display::set_icon("icon.png");
// Game loop
asw::display::clear();
// draw here...
asw::display::present();