bgfx: conform to the canonical window + input contracts (epic #386 Phase 3) - #394
Conversation
Rename the bgfx window methods from the raylib dialect to labelle-core's canonical window-contract names and prove conformance at comptime: beginDrawing -> beginFrame endDrawing -> endFrame getScreenWidth -> width getScreenHeight -> height windowShouldClose -> shouldQuit (frameDuration / requestQuit / setFullscreen / setVsync / isFullscreen / takeScreenshot were already canonical and are unchanged.) The render backend's own getScreenWidth/getScreenHeight (gfx.zig / gfx/state.zig) are the DIFFERENT render contract and are deliberately left untouched. - Bump labelle_core pin 1.16.1 -> 1.21.0 (carries window_contract.zig). - window.zig: import labelle-core + comptime core.assertWindow(@this()); rename the 5 decls + every internal caller/comment; rename the shadowed width/height params in initWindow* to w/h (Zig 0.16 rejects a param that shadows the new top-level width()/height() decls). - input.zig: wire the previously duck-typed contract claim into a real comptime core.assertInput(@this()). - build.zig: import labelle-core onto window_mod + input_mod on every target (comptime-only asserts, no core type crosses the engine seam, so no codegen unification needed beyond the existing Android input override). - templates/desktop.txt + android.txt and example/main.zig + android_video.zig: update the run-loop call sites to canonical names. Verified: zig build + zig build test green (host and -Dtarget=aarch64-linux-android); the bgfx example builds.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe bgfx backend's public window API is renamed to match the Changesbgfx Window/Input API Rename and Contract Enforcement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the bgfx backend to conform to the canonical window and input contracts defined in labelle-core (v1.21.0). Comptime assertions (core.assertInput and core.assertWindow) have been added to verify contract conformance, and several window API functions have been renamed to match the canonical contract (e.g., getScreenWidth/getScreenHeight to width/height, beginDrawing/endDrawing to beginFrame/endFrame, and windowShouldClose to shouldQuit). There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…lete (#395) gfx.zig's façade already exposed every required render decl (types/draw fns/ colors + the paired isCompressed/uploadCompressed); this adds the compile-time core.assertBackend(@this()) gate that PROVES it, replacing the old prose 'satisfies Backend(Impl)' doc claim. Wires labelle-core onto gfx_mod (gfx_tests builds from it). Completes bgfx's contract trifecta: render + window (assertWindow, #394) + input (assertInput, #394). Build/test/Android cross-build green. #386 Phase 3.
First backend conformed to labelle-core's canonical window contract (v1.21.0) — the user's chosen "canonical rename (unify)" path. bgfx is FP's backend and the Phase-4 GPU-context-gate backend, so it's the highest-leverage one to do first.
Renames (
backends/bgfx/src/window.zig)beginDrawing→beginFrame,endDrawing→endFrame,getScreenWidth→width,getScreenHeight→height,windowShouldClose→shouldQuit. Already-canonical methods (frameDuration/requestQuit/setFullscreen/setVsync/isFullscreen/takeScreenshot/initWindow) unchanged. All call sites updated:android_app.zig,templates/{desktop,android}.txt,example/{main,android_video}.zig.Collision respected
The render backend's own
getScreenWidth/getScreenHeightingfx/state.zig(thebackend_contractrequired methods, returning the design canvas) are a DIFFERENT contract — untouched. Only the window's (live framebuffer size) were renamed.Proves conformance
comptime core.assertWindow(@This())in window.zig +comptime core.assertInput(@This())in input.zig — compile-time gates that fail with a named-decl list if anything's missing. They compile ⇒ bgfx provably satisfies both contracts. bgfx declaresshouldQuit⇒ correctly a loop backend (ownsLoop()true).Note
width()/height()decls shadowedinitWindow'swidth/heightparams (Zig 0.16 rejects) → params renamed tow/h(mechanical).Verified
backends/bgfxzig build+zig build testgreen (19/19); Android cross-build (-Dtarget=aarch64-linux-android) green; the bgfx example builds. The comptime asserts cross no core types over the engine seam ⇒ no codegen-unification change needed.Part of epic #386 Phase 3 (window+input contracts → conform backends). sokol already speaks the canonical dialect; raylib (still
beginDrawing/getScreenWidth) follows.Summary by CodeRabbit