kanzi::FPSConstraints Class Reference

Constraint for limiting the number of frames per second the Engine is rendering. More...

#include <kanzi/core.ui/application/fps_constraints.hpp>

Public Member Functions

 FPSConstraints ()
 Constructor Sets desired framerate to 60. More...
 
void setDesiredFrameRate (unsigned int frameRate)
 Sets desired framerate as frames per second. More...
 
chrono::milliseconds 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. More...
 
void update (chrono::milliseconds delta)
 Update constraints tracking with frame time. More...
 
chrono::milliseconds getTargetFrameTime () const
 Gets the target frame time in milliseconds. More...
 
bool isEnabled () const
 Tells if frame rate limiting is enabled. More...
 
void setEnabled (bool enable)
 Turn frame rate limit on or off. More...
 

Detailed Description

Constraint for limiting the number of frames per second the Engine is rendering.

Constructor & Destructor Documentation

kanzi::FPSConstraints::FPSConstraints ( )
explicit

Constructor Sets desired framerate to 60.

Member Function Documentation

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
frameRateFramerate 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
deltaTimeTime 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
deltaTime 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
enableNew state.

The documentation for this class was generated from the following file: