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.
 
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
 
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 [1/2]

◆ clock [2/2]

◆ duration [1/2]

◆ duration [2/2]

◆ time_point [1/2]

◆ time_point [2/2]

Member Function Documentation

◆ interval() [1/2]

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

◆ interval() [2/2]

int nngn::FrameLimiter::interval ( void  ) const
inline

◆ limit() [1/2]

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:

◆ limit() [2/2]

void nngn::FrameLimiter::limit ( void  )

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

◆ set_interval() [1/2]

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

◆ set_interval() [2/2]

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: