Skip to content

WidgetPass

WidgetPass is the top-most UI pass. It renders immediate-mode UI widgets - panels, buttons, sliders, and other controls - over the fully composited scene image. It runs after TextPass and before PostProcessPass.

Render Graph Role

AttributeValue
GroupUI
Reads-
Read-Writescene_color
CullableYes

Widget Entities

Widgets are defined by attaching a WidgetComponent to an entity. The component holds the widget tree root, which is traversed each frame by WidgetPass:

cpp
auto* hud = add_entity<Object>("HUD");
auto* widget = hud->add_component<WidgetComponent>();

widget->root = Panel::create({
    .position = { 16, 16 },
    .size     = { 200, 120 },
    .children = {
        Label::create("Score: 0"),
        Button::create("Restart", on_restart),
    },
});

Rendering

WidgetPass traverses the widget tree depth-first and emits a draw list of textured or colored quads. The draw list is sorted by Z-order and submitted as a single batched draw call with a shared atlas texture for glyphs and icons.

Alpha blending is enabled for the duration of the pass.

Coordinate System

Widget positions are in window pixel space, origin at top-left, matching TextPass.

Interaction

Input events (mouse clicks, key presses) are forwarded to the widget system separately - WidgetPass is render-only and has no input handling logic.