fix: support OpenGL renderer in Linux lib (embedded) builds - #95
fix: support OpenGL renderer in Linux lib (embedded) builds#95ddaydroid wants to merge 2 commits into
Conversation
Building libghostty on Linux with -Dapp-runtime=none previously failed: - glad was only compiled into non-lib artifacts, leaving gladLoaderLoadGLContext/gladLoaderUnloadGLContext undefined in the shared lib. Compile glad for Linux lib artifacts too. - renderer/OpenGL.zig displayRealized had a comptime guard allowing only the GTK apprt. Allow the embedded apprt with the same contract: the host realizes the GL display and makes the context current before calling in.
📝 WalkthroughWalkthroughBuild configuration now compiles vendored glad OpenGL sources for Linux library builds in addition to non-library builds, via a new ChangesGlad and embedded runtime OpenGL support
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes two gaps that prevented
Confidence Score: 4/5Safe to merge — the changes are narrowly scoped to the Linux lib build path and a compile-time switch extension; no existing build configurations are affected. Both changes are small and targeted. The OpenGL renderer change is a clean symmetrical extension. The only open question is whether src/build/SharedDeps.zig — the Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Host as Embedded Host (cmux)
participant Lib as libghostty (Linux)
participant GL as OpenGL Renderer
participant Glad as glad (gl.c)
Host->>Lib: initialize libghostty
Note over Lib,Glad: glad now compiled into Linux lib builds
Host->>Host: "create GL context & make current"
Host->>Lib: call displayRealized()
Lib->>GL: displayRealized() [apprt.embedded]
GL->>Glad: prepareContext(null)
Glad-->>GL: GL function pointers loaded
GL-->>Lib: ok
Lib-->>Host: display ready
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Host as Embedded Host (cmux)
participant Lib as libghostty (Linux)
participant GL as OpenGL Renderer
participant Glad as glad (gl.c)
Host->>Lib: initialize libghostty
Note over Lib,Glad: glad now compiled into Linux lib builds
Host->>Host: "create GL context & make current"
Host->>Lib: call displayRealized()
Lib->>GL: displayRealized() [apprt.embedded]
GL->>Glad: prepareContext(null)
Glad-->>GL: GL function pointers loaded
GL-->>Lib: ok
Lib-->>Host: display ready
Reviews (1): Last reviewed commit: "fix: support OpenGL renderer in Linux li..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/OpenGL.zig (1)
172-176: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale TODO in
surfaceInitfor embedded.The TODO at line 173 states libghostty is "strictly broken for rendering on this platforms," but
displayRealizednow actively prepares the GL context for embedded. WhilesurfaceInitandthreadEnterstill no-op for embedded (by design — the host handles those responsibilities), the "strictly broken" characterization is no longer fully accurate. Consider updating the TODO to reflect the new state.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/renderer/OpenGL.zig` around lines 172 - 176, The stale TODO in surfaceInit’s apprt.embedded branch no longer matches the current embedded GL flow, since displayRealized now prepares the context. Update the comment near surfaceInit to reflect that embedded rendering setup is now partially handled by displayRealized while surfaceInit and threadEnter remain intentional no-ops, and remove the “strictly broken” wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/renderer/OpenGL.zig`:
- Around line 172-176: The stale TODO in surfaceInit’s apprt.embedded branch no
longer matches the current embedded GL flow, since displayRealized now prepares
the context. Update the comment near surfaceInit to reflect that embedded
rendering setup is now partially handled by displayRealized while surfaceInit
and threadEnter remain intentional no-ops, and remove the “strictly broken”
wording.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 013b4044-a6a9-4c7f-9f1e-4dccd70ca777
📒 Files selected for processing (2)
src/build/SharedDeps.zigsrc/renderer/OpenGL.zig
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Building libghostty on Linux with -Dapp-runtime=none previously failed:
gladLoaderLoadGLContext/gladLoaderUnloadGLContext undefined in the
shared lib. Compile glad for Linux lib artifacts too.
the GTK apprt. Allow the embedded apprt with the same contract: the
host realizes the GL display and makes the context current before
calling in.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Fixes OpenGL renderer support for Linux embedded
libghosttybuilds. Compilesgladfor Linux lib targets when using the OpenGL renderer and lets the embedded runtime calldisplayRealizedwith the same GL-context contract as GTK.gladinto Linux lib artifacts on Linux when renderer is.openglto providegladLoader*symbols.apprt.embeddedinrenderer/OpenGL.zigso hosts pre-create and bind the GL context before calling in.Written for commit 99256d2. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes