QtCraft API C++ classes QML types Handbook

QcFramePacer Class

Frame pacing of the game window (decision E-835): with a limit, frames start at most that many times a second, on a grid so that early or late frames do not change the rate; without one (0), every frame is due at once. More...

Header: #include <clientcore/preview/QcFramePacer.h>

Public Functions

qint64 delayNs(qint64 nowNs) const
bool frameDue(qint64 nowNs)
qint64 intervalNs() const
int limit() const
void reset()
void setLimit(int framesPerSecond)

Detailed Description

The clock is passed in (nanoseconds of a monotonic clock), so the rules are testable; QcFrameLimiter asks it before every frame and times the next request.

Member Function Documentation

qint64 QcFramePacer::delayNs(qint64 nowNs) const

Returns the time in nanoseconds from nowNs until the next frame is due; 0 when it is due now (or without a limit).

bool QcFramePacer::frameDue(qint64 nowNs)

Returns whether a frame may start at nowNs; when it says yes, the frame counts as started. A frame up to a millisecond early still counts (timers fire early).

qint64 QcFramePacer::intervalNs() const

Returns the shortest time between two frames in nanoseconds; 0 without a limit.

int QcFramePacer::limit() const

Returns the limit in frames per second; 0 is no limit.

See also setLimit().

void QcFramePacer::reset()

The next frame is due at once (after a pause or a change of the limit).

void QcFramePacer::setLimit(int framesPerSecond)

Sets the limit to framesPerSecond; 0 is no limit. Negative values count as 0.

See also limit().