Simple Game Graphics Library 1.1
|
Functions | |
void | setDrawFunction (std::function< void()> draw) |
void | setPreDrawFunction (std::function< void()> predraw) |
void | setPostDrawFunction (std::function< void()> postdraw) |
void | setUpdateFunction (std::function< void(float)> update) |
void | setResizeFunction (std::function< void(int, int)> resize) |
void 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 setPostDrawFunction | ( | std::function< void()> | postdraw | ) |
Specifies a function to call after entering the 2D rendering draw call.
The post-draw function is useful when one needs to render 3D content or call custom rendering functionality that is going to write over the 2D canvas typically generated with SGG functions. For example, one can use SGG to draw a GUI and draw a custom video overlay as a post-draw operation over some part of it.
postdraw | is the user-defined draw function passed to call. |
void setPreDrawFunction | ( | std::function< void()> | predraw | ) |
Specifies a function to call prior to entering the 2D rendering draw call.
The pre-draw function is useful when one needs to render 3D content or call custom rendering functionality prior to drawing a 2D overlay over it. For example, one can use typical 3D graphics to render a 3D game view and overlay the 3D view with a GUI created with SGG.
predraw | is the user-defined draw function passed to call. |
void 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 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: