nngn
Loading...
Searching...
No Matches
nngn::FrameLimiter Class Reference

Simulates a v-sync pause using sleep. More...

#include <limit.h>

Public Member Functions

int interval (void) const
 
void set_interval (int i)
 
void limit (void)
 Sleeps for as long as necessary to maintain a constant frame rate.
 

Private Types

using time_point = nngn::Timing::time_point
 
using clock = nngn::Timing::clock
 
using duration = nngn::Timing::duration
 

Private Attributes

int m_interval = 1
 
time_point last = clock::now()
 

Detailed Description

Simulates a v-sync pause using sleep.

limit should be called once at the end of each frame. A constant rate of 60FPS, scaled by the inverse of interval, is maintained no matter the duration between each call to limit.

If one cycle takes too long, limit returns immediately a number of times necessary to generate the correct amount of frames as if the rate had been maintained (i.e. frames are not skipped).

Member Typedef Documentation

◆ clock

◆ duration

◆ time_point

Member Function Documentation

◆ interval()

int nngn::FrameLimiter::interval ( void ) const
inline
Here is the caller graph for this function:

◆ limit()

void nngn::FrameLimiter::limit ( void )

Sleeps for as long as necessary to maintain a constant frame rate.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_interval()

void nngn::FrameLimiter::set_interval ( int i)
inline

Member Data Documentation

◆ last

time_point nngn::FrameLimiter::last = clock::now()
private

◆ m_interval

int nngn::FrameLimiter::m_interval = 1
private

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