mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
initialize glfw in app
This commit is contained in:
@ -59,6 +59,10 @@ pub const Darwin = struct {
|
|||||||
/// up the renderer state, compiles the shaders, etc. This is the primary
|
/// up the renderer state, compiles the shaders, etc. This is the primary
|
||||||
/// "startup" logic.
|
/// "startup" logic.
|
||||||
pub fn create(alloc: Allocator, config: *const Config) !*App {
|
pub fn create(alloc: Allocator, config: *const Config) !*App {
|
||||||
|
// Initialize glfw
|
||||||
|
try glfw.init(.{});
|
||||||
|
errdefer glfw.terminate();
|
||||||
|
|
||||||
// The mailbox for messaging this thread
|
// The mailbox for messaging this thread
|
||||||
var mailbox = try Mailbox.create(alloc);
|
var mailbox = try Mailbox.create(alloc);
|
||||||
errdefer mailbox.destroy(alloc);
|
errdefer mailbox.destroy(alloc);
|
||||||
@ -111,6 +115,9 @@ pub fn destroy(self: *App) void {
|
|||||||
if (comptime builtin.target.isDarwin()) self.darwin.deinit();
|
if (comptime builtin.target.isDarwin()) self.darwin.deinit();
|
||||||
self.mailbox.destroy(self.alloc);
|
self.mailbox.destroy(self.alloc);
|
||||||
self.alloc.destroy(self);
|
self.alloc.destroy(self);
|
||||||
|
|
||||||
|
// Close our windowing runtime
|
||||||
|
glfw.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wake up the app event loop. This should be called after any messages
|
/// Wake up the app event loop. This should be called after any messages
|
||||||
|
@ -131,10 +131,6 @@ pub fn main() !void {
|
|||||||
// We want to log all our errors
|
// We want to log all our errors
|
||||||
glfw.setErrorCallback(glfwErrorCallback);
|
glfw.setErrorCallback(glfwErrorCallback);
|
||||||
|
|
||||||
// Initialize glfw
|
|
||||||
try glfw.init(.{});
|
|
||||||
defer glfw.terminate();
|
|
||||||
|
|
||||||
// Run our app
|
// Run our app
|
||||||
var app = try App.create(alloc, &config);
|
var app = try App.create(alloc, &config);
|
||||||
defer app.destroy();
|
defer app.destroy();
|
||||||
|
Reference in New Issue
Block a user