From a922b4b29b95c4649bb46046c92cf84623405ae7 Mon Sep 17 00:00:00 2001 From: iddev5 Date: Sun, 17 Apr 2022 23:48:08 +0530 Subject: [PATCH] mach: set error message to be shown on glfw error This uses glfw.setErrorCallback to set a global callback in mach's App which would work across all mach applications --- src/main.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.zig b/src/main.zig index 34167027..36330da2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -52,6 +52,11 @@ pub const Options = struct { power_preference: gpu.PowerPreference = .none, }; +/// Default GLFW error handling callback +fn glfwErrorCallback(error_code: glfw.Error, description: [:0]const u8) void { + std.debug.print("glfw: {}: {s}\n", .{ error_code, description }); +} + /// A Mach application. /// /// The Context type is your own data type which can later be accessed via app.context from within @@ -87,6 +92,7 @@ pub fn App(comptime Context: type, comptime config: AppConfig) type { pub fn init(allocator: std.mem.Allocator, context: Context, options: Options) !Self { const backend_type = try util.detectBackendType(allocator); + glfw.setErrorCallback(glfwErrorCallback); try glfw.init(.{}); // Create the test window and discover adapters using it (esp. for OpenGL)