Drives a game: fixed-rate updates, then one render per frame.
Definition loop.hpp:23
std::function< void(double alpha)> RenderFn
Rendering callback, called with FixedTimestep::alpha().
Definition loop.hpp:28
MainLoop(FixedTimestep timestep) noexcept
Creates a stopped loop.
void stop() noexcept
Makes run() return after the current frame. Thread-safe.
void set_render(RenderFn render)
Sets the rendering callback (none by default: the loop then sleeps between steps).
void run()
Runs frames until stop() is called. A stop() made before run() is ignored.
std::function< void(Duration step)> UpdateFn
Simulation callback, called with the fixed step duration.
Definition loop.hpp:26
void set_update(UpdateFn update)
Sets the simulation callback (none by default).