|
libtcod
|
A timing class based on SDL's high performance time counter. More...
#include <timer.hpp>
Public Member Functions | |
| Timer () | |
| Construct a new Timer object. | |
| float | sync (int desired_fps=0) |
| Sync the time to a given framerate (if provided) and return the delta time compared to the previous call. | |
| float | get_mean_fps () const noexcept |
| Return the mean framerate. | |
| float | get_last_fps () const noexcept |
| Return the framerate of the last call to sync(). | |
| float | get_min_fps () const noexcept |
| Return the lowest framerate recently sampled. | |
| float | get_max_fps () const noexcept |
| Return the highest framerate recently sampled. | |
| float | get_median_fps () const noexcept |
| Return the median framerate. | |
A timing class based on SDL's high performance time counter.
Used to track delta time or set a framerate.
This class is based on using SDL_GetPerformanceCounter to track the time. The time taken between calls to sync() is tracked. This is used to determine the real framerate if requested.
You must add #include <libtcod/timer.hpp> to include ths class.
embed:rst:leading-asterisk .. versionadded:: 1.19
|
inlinenodiscardnoexcept |
Return the mean framerate.
This is the average of all samples combined.
|
inlinenodiscardnoexcept |
Return the median framerate.
This is the framerate of the middle sample when all samples are sorted.
|
inline |
Sync the time to a given framerate (if provided) and return the delta time compared to the previous call.
If desired_fps is non-zero then this function will block until the desired framerate is reached.
Timing starts once the Timer is constructed.
| desired_fps | The desired framerate in frames-per-second, or zero to disable framerate limiting. |