FrameTimer
Frame-oriented timer for computing clamped delta time.
The frame timer builds on top of Timer to provide a simple, per-frame timestep suitable for driving simulations and animations. Each call to Tick returns the elapsed time since the previous call, clamped by max_delta to guard against stalls (e.g., window drags, breakpoints).
cpp
auto frame_timer = vglx::FrameTimer {true}; // auto-start
while (running) {
const auto dt = frame_timer.Tick();
scene.Advance(dt);
renderer.Render(&scene, &camera);
}Construction
Constructors
FrameTimer()
Constructs a frame timer.
cpp
FrameTimer::FrameTimer(bool auto_start);| Parameter | Description |
|---|---|
| auto_start | Starts timer immediately upon construction. |
Functions
Start() void
Starts the internal timer.
Also initializes the internal reference time so the next call to Tick returns the true frame delta.
cpp
void FrameTimer::Start();