Struct FrameContext

Struct Documentation

struct FrameContext

Per-frame context data passed to all module lifecycle methods.

FrameContext is the primary data structure that flows through the Application’s main loop, carrying essential per-frame state to every module’s lifecycle hooks (begin_frame, update, gui_update, post_update, end_frame). This structure enables modules to access shared frame state and resources without direct dependencies on each other.

The same FrameContext instance is passed through an entire frame’s execution, allowing modules to communicate through the stats field or share the rendering context. The frame_index wraps around based on frames_in_flight (typically 3) to support multi-buffering in the renderer.

Lifecycle flow:

  1. Application creates a new FrameContext at the start of each frame

  2. Passes it to modules.begin_frame(context)

  3. Passes it through modules.update(context)

  4. Passes it through modules.gui_update(context)

  5. Passes it through modules.post_update(context) for rendering

  6. Passes it to modules.end_frame(context) for cleanup

Public Members

size_t frame_index
float delta_time
FrameStats stats = {}
ecs::Registry *ecs_registry = nullptr
Scene *active_scene = nullptr
std::any rendering_context = std::any{}