ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::core Namespace Reference

Functions

void update ()
 Updates core module functionality.
 
float get_delta_time ()
 Get the time between the last two calls to update(). Capped at a quarter of a second, so a breakpoint or a stalled window does not send things flying.
 
void run (const std::function< void()> &frame)
 Run a main loop until exit() is called.
 
void init (int width, int height, int scale=1)
 Initializes the core module.
 
void init_opengl (int width, int height, int scale=1)
 Initializes the core module for opengl.
 
void print_info ()
 Prints information about the core module.
 
void exit ()
 Exit the application. Sets exiting flag to true, which will cause the main loop to exit on the next update.
 
bool is_exiting ()
 Return exiting status.
 
void shutdown ()
 Cleanup resources used by the core module. Should be called on application exit.
 

Function Documentation

◆ exit()

void asw::core::exit ( )

Exit the application. Sets exiting flag to true, which will cause the main loop to exit on the next update.

Definition at line 227 of file core.cpp.

◆ get_delta_time()

float asw::core::get_delta_time ( )

Get the time between the last two calls to update(). Capped at a quarter of a second, so a breakpoint or a stalled window does not send things flying.

Returns
The frame time in seconds, 0 before the second update.

Definition at line 163 of file core.cpp.

◆ init()

void asw::core::init ( int width,
int height,
int scale = 1 )

Initializes the core module.

Parameters
widthThe width of the window.
heightThe height of the window.
scaleThe scale of the window.

Definition at line 168 of file core.cpp.

◆ init_opengl()

void asw::core::init_opengl ( int width,
int height,
int scale = 1 )

Initializes the core module for opengl.

Parameters
widthThe width of the window.
heightThe height of the window.
scaleThe scale of the window.

Definition at line 187 of file core.cpp.

◆ is_exiting()

bool asw::core::is_exiting ( )

Return exiting status.

Definition at line 289 of file core.cpp.

◆ print_info()

void asw::core::print_info ( )

Prints information about the core module.

Definition at line 212 of file core.cpp.

◆ run()

void asw::core::run ( const std::function< void()> & frame)

Run a main loop until exit() is called.

Calls frame once per frame. Call update() and asw::display::present() inside it as usual. On desktop this is a plain loop that returns once exit() is called. In the browser (Emscripten) the browser drives the loop, so run() does not return and code after it never runs; the loop stops when exit() is called, and Module.onStop is called if the page defines it.

Parameters
frameThe function to call each frame.

Definition at line 257 of file core.cpp.

◆ shutdown()

void asw::core::shutdown ( )

Cleanup resources used by the core module. Should be called on application exit.

Definition at line 232 of file core.cpp.

◆ update()

void asw::core::update ( )

Updates core module functionality.

Definition at line 32 of file core.cpp.