Skip to content

renderer

FreeBodyEngine.ui.renderer #

UIRenderer() #

Bases: Service

Engine service that draws the UI tree owned by the ui service (UIManager).

Loads the shared background quad mesh/material used to draw every element.

material = load_file('engine://ui/element.fbmat') instance-attribute #

quad = generate_quad() instance-attribute #

draw() #

Draws every top-level element of the UI tree (and, recursively, their children).

Depth testing is explicitly turned off first, then back on after - nothing here ever did this before, so the UI silently inherited whatever depth-test state the 3D pipeline (PBRPipeline) happened to leave behind (on for its opaque/lighting passes - see graphics/pbr/pipeline.py - off only during its own composite step). Every UI element's background and text share the same mesh, drawn at the same implicit depth, in the same frame's depth buffer as whatever 3D content came before - with depth testing left on and GL's default depth func (GL_LESS), a background quad writes a depth value that its own text quad, drawn microseconds later at that identical depth, then fails to beat ("less than", not "less-or-equal") - so the text silently doesn't draw. Which specific elements this hits depends on incidental depth-buffer contents from whatever 3D drawing happened to precede them that frame, which is exactly the "some buttons show their label, some don't, no obvious pattern" bug this fixes. A 2D overlay drawn last in painter's-algorithm order (later siblings on top - see _draw_element's docs) was never supposed to depend on the depth buffer at all.

on_destroy() #

Unregisters the draw callback registered in on_initialize.

on_initialize() #

Registers the draw callback and grabs a reference to the ui service's tree.