CGPdocs

timer_basic

Timer accumulating the elapsed time t (update() returns the time step), with start, stop and a speed factor.

The same irregular frames seen by the three timers: timer_basic.t grows by dt at each update, timer_interval.t loops back to t_min when it reaches t_max, and timer_event_periodic sets event to true at the first frame after each period has elapsed.
The same irregular frames seen by the three timers: timer_basic.t grows by dt at each update, timer_interval.t loops back to t_min when it reaches t_max, and timer_event_periodic sets event to true at the first frame after each period has elapsed. Tap to enlarge.

Fields and methods

Members of the struct timer_basic. Most of what you do with a CGP type goes through the free functions listed below.

Fields

float tAccumulated time in seconds, multiplied by scale, 0 until the second update().
float scaleMultiplier applied to the elapsed real time (1 by default; larger values accelerate the animation).

Methods

Builds a running timer with t = 0 and scale = 1; time is measured from the first update() or start(), so the time spent loading the scene is not counted. src
Advances t by the elapsed real time since the previous update (or start) times scale and returns this time step in seconds; the first call after construction returns 0, and a stopped timer returns 0 without change. src
Resumes the timer, measuring the next time step from now (the time spent stopped is not counted). src
Pauses the timer; update() then returns 0 and t stays constant. src

Functions taking a timer_basic

None.

Functions returning a timer_basic

None.

Operators

None.

CGP - Computer Graphics Programming.