Simple Game Graphics Library
1.0
|
Functions | |
void | graphics::setDrawFunction (std::function< void()> draw) |
void | graphics::setUpdateFunction (std::function< void(float)> update) |
void | graphics::setResizeFunction (std::function< void(int, int)> resize) |
void graphics::setDrawFunction | ( | std::function< void()> | draw | ) |
Specifies a user-defined function to be called each time the window is to be redisplayed.
The custom draw function is the only one that should contain all SGG draw functions to be used for painting the contents of the canvas. Drawing occurs a) when a window size change is reported, b) at predetermied and equally spaced intervals, triggered by the event processing loop of the SGG engine.
draw | is the user-defined draw function passed. |
Typical usage:
void graphics::setResizeFunction | ( | std::function< void(int, int)> | resize | ) |
Specifies a user-defined function to be called each time the window is resized.
Typically, there is no need to call this function in most situations, as the dimensions of the window and the drawing canvas are independent. Still, in some case, one may want to change what is displayed according to the available screen area, or adapt the aspect ratio of the canvas to match that of the host window.
resize | is the user-defined function passed. The callback function must accept two int parameters, the new width and height of the window. |
Potential usage:
void graphics::setUpdateFunction | ( | std::function< void(float)> | update | ) |
Specifies a user-defined function to be called each time the state of the application needs to be updated.
This callback function is invoked a) when an input event is triggered in the event processing loop of the engine, such as mouse state change or keyboard key press, b) at regularly timed intervals, so that time-dependent states in the application (such as animations, collisions, simulations) may advance their values.
Typically, in the update callback function the developer places code for polling the input devices and using the time increment (passed as an argument) to update the application mechanics. Keep also in mind that the time increment passed in the callback is also globally available thoughout the code through the getDeltaTime() function.
update | is the user-defined function passed. The callback function must accept a single parameter, the time passed in miliseconds from the last triggered update. |
Typical usage: