Skip to content

Commit 5a6f6ee

Browse files
committed
enable out of tree use of opengl renderer
1 parent f46a36f commit 5a6f6ee

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/ghostty.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ pub const input = @import("input.zig");
66
pub const internal_os = @import("os/main.zig");
77
pub const renderer = @import("renderer.zig");
88
pub const terminal = @import("terminal/main.zig");
9-
pub const CoreApp = @import("App.zig");
10-
pub const CoreSurface = @import("Surface.zig");
9+
pub const Surface = @import("Surface.zig");
1110
pub const config = @import("config.zig");
11+
pub const gl = @import("opengl");

src/renderer/OpenGL.zig

+8-5
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ pub fn surfaceInit(surface: *apprt.Surface) !void {
451451
const self: OpenGL = undefined;
452452

453453
switch (apprt.runtime) {
454-
else => @compileError("unsupported app runtime for OpenGL"),
454+
else => try self.threadEnter(surface),
455455

456456
apprt.gtk => {
457457
// GTK uses global OpenGL context so we load from null.
@@ -491,12 +491,13 @@ pub fn surfaceInit(surface: *apprt.Surface) !void {
491491
/// final main thread setup requirements.
492492
pub fn finalizeSurfaceInit(self: *const OpenGL, surface: *apprt.Surface) !void {
493493
_ = self;
494-
_ = surface;
495494

496495
// For GLFW, we grabbed the OpenGL context in surfaceInit and we
497496
// need to release it before we start the renderer thread.
498497
if (apprt.runtime == apprt.glfw) {
499498
glfw.makeContextCurrent(null);
499+
} else {
500+
try surface.finalizeSurfaceInit();
500501
}
501502
}
502503

@@ -555,7 +556,7 @@ pub fn threadEnter(self: *const OpenGL, surface: *apprt.Surface) !void {
555556
_ = self;
556557

557558
switch (apprt.runtime) {
558-
else => @compileError("unsupported app runtime for OpenGL"),
559+
else => try surface.threadEnter(),
559560

560561
apprt.gtk => {
561562
// GTK doesn't support threaded OpenGL operations as far as I can
@@ -597,7 +598,9 @@ pub fn threadExit(self: *const OpenGL) void {
597598
_ = self;
598599

599600
switch (apprt.runtime) {
600-
else => @compileError("unsupported app runtime for OpenGL"),
601+
else => {
602+
// TODO: send to apprt
603+
},
601604

602605
apprt.gtk => {
603606
// We don't need to do any unloading for GTK because we may
@@ -2332,7 +2335,7 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
23322335
apprt.glfw => surface.window.swapBuffers(),
23332336
apprt.gtk => {},
23342337
apprt.embedded => {},
2335-
else => @compileError("unsupported runtime"),
2338+
else => try surface.swapBuffers(),
23362339
}
23372340
}
23382341

0 commit comments

Comments
 (0)