Skip to content

Stats

Collects and visualizes runtime performance statistics.

This class tracks frames per second, frame time, and the number of rendered objects per frame. It is used by the runtime when show_stats is set to true to provide an on-screen performance overlay during development and debugging.

cpp
while (running) {
  stats.BeforeRender();
  renderer.Render(scene, camera);
  stats.AfterRender(renderer.RenderedObjectsPerFrame());
  stats.Draw();
}

This overlay currently requires ImGui support. If the engine is not compiled with VGLX_USE_IMGUI, the Draw method becomes a no-op.

Construction

Constructors


Stats()

Constructs a stats object.

cpp
Stats::Stats();

Functions

AfterRender() void

Marks the end of a frame render.

Updates frame time and records the number of rendered objects. The number of objects can be retrieved from the renderer.

cpp
void Stats::AfterRender(unsigned n_objects);
ParameterDescription
n_objectsNumber of objects rendered in the frame.

BeforeRender() void

Marks the beginning of a frame render.

Records timing information and increments the frame counter. Call this before issuing any render commands.

cpp
void Stats::BeforeRender();

Draw() void

Draws the performance overlay.

Renders a window containing FPS, frame time, and rendered object histograms.

cpp
void Stats::Draw() const;

Released under the MIT License.