Constraint for limiting the number of frames per second the Engine is rendering.
More...
#include <kanzi/core.ui/application/fps_constraints.hpp>
Constraint for limiting the number of frames per second the Engine is rendering.
kanzi::FPSConstraints::FPSConstraints |
( |
| ) |
|
|
explicit |
Constructor Sets desired framerate to 60.
void kanzi::FPSConstraints::setDesiredFrameRate |
( |
unsigned int |
frameRate | ) |
|
Sets desired framerate as frames per second.
The desired framerate represents the number of frames per second the program should render. In heavy load, framerate may be smaller if rendering frames takes too long. In practice the framerate may also be very slightly higher (due to time measurement inaccuracies). This is the reason it's called desired framerate - the system is aiming to the framerate but cannot guarantee exact numbers.
- Parameters
-
frameRate | Framerate to aim for. |
chrono::milliseconds kanzi::FPSConstraints::getProposedSleepTime |
( |
chrono::milliseconds |
deltaTime | ) |
const |
Gets the time main thread can sleep in milliseconds, supposing given duration would have passed from the start of the frame.
The time passed is used to determine the remaining sleep time this frame, for example when called after rendering.
- Parameters
-
deltaTime | Time passed since the frame started. |
- Returns
- Maximum time the main thread should sleep. Always nonnegative.
void kanzi::FPSConstraints::update |
( |
chrono::milliseconds |
delta | ) |
|
Update constraints tracking with frame time.
- Parameters
-
delta | Time delta since last frame. |
chrono::milliseconds kanzi::FPSConstraints::getTargetFrameTime |
( |
| ) |
const |
|
inline |
Gets the target frame time in milliseconds.
This is the number of milliseconds each rendering of a frame should take. This number is rounded down if exact frame time is not an integer.
- Returns
- Frame time in milliseconds, rounded down.
bool kanzi::FPSConstraints::isEnabled |
( |
| ) |
const |
|
inline |
Tells if frame rate limiting is enabled.
- Returns
- True if framerate is limited, false if unlimited.
void kanzi::FPSConstraints::setEnabled |
( |
bool |
enable | ) |
|
|
inline |
Turn frame rate limit on or off.
- Parameters
-
The documentation for this class was generated from the following file: