vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::FrameLimiter Class Reference

Limits a render loop's frame rate by sleeping, then spin-waiting. More...

#include <frame_limiter.h>

Public Member Functions

 FrameLimiter ()
 Ask Windows for a 1 ms scheduler tick for as long as the limiter lives.
void beginFrame ()
 Marks the start of a frame, before any work is done.
void endFrame ()
 Marks the end of a frame and waits as necessary to match the target framerate.
void setTargetFramerate (int framerate)
 Set the desired target framerate (frames per second).
int targetFramerate () const
 The cap in effect, in frames per second.

Detailed Description

Limits a render loop's frame rate by sleeping, then spin-waiting.

A target of 0 disables it.

Constructor & Destructor Documentation

◆ FrameLimiter()

Vkm::Engine::FrameLimiter::FrameLimiter ( )

Ask Windows for a 1 ms scheduler tick for as long as the limiter lives.

Otherwise a sleep wakes on the default 15.6 ms tick. A no-op on Linux.

Member Function Documentation

◆ setTargetFramerate()

void Vkm::Engine::FrameLimiter::setTargetFramerate ( int framerate)
inline

Set the desired target framerate (frames per second).

Parameters
framerateDesired framerate in FPS; 0 or less disables the limiter.

◆ targetFramerate()

int Vkm::Engine::FrameLimiter::targetFramerate ( ) const
inline

The cap in effect, in frames per second.

Returns
The target framerate, or 0 when the limiter is disabled.

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