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
setTitle
void setTitle(const std::string& title);Set the title of the window.
| Parameter | Type | Description |
|---|---|---|
title | const std::string& | The title to display at the top of the window |
setIcon
void setIcon(const std::string& path);Set the icon to display on the window. Silently fails if the file does not exist.
| Parameter | Type | Description |
|---|---|---|
path | const std::string& | Path to the icon file |
setFullscreen
void setFullscreen(bool fullscreen);Set the window to fullscreen or windowed mode.
setResolution
void setResolution(int w, int h);Set the resolution of the window.
| Parameter | Type | Description |
|---|---|---|
w | int | Width of the window |
h | int | Height of the window |
setResizable
void setResizable(bool resizable);Set whether the window is resizable.
getSize
SDL_Point getSize();Returns the actual size of the window.
getLogicalSize
SDL_Point getLogicalSize();Returns the logical size of the window. This may differ from the actual size if scaling is enabled.
getScale
SDL_FPoint getScale();Returns the scale of the window (logical size / actual size).
setRenderTarget
void setRenderTarget(const asw::Texture& texture);Set the render target to a texture.
resetRenderTarget
void resetRenderTarget();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.
setBlendMode
void setBlendMode(asw::BlendMode mode);Set the blend mode of the renderer.
Example
asw::display::setTitle("My Game");
asw::display::setIcon("icon.png");
// Game loop
asw::display::clear();
// draw here...
asw::display::present();