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
This commit is contained in:
parent
27146af8ce
commit
a922b4b29b
1 changed files with 6 additions and 0 deletions
|
|
@ -52,6 +52,11 @@ pub const Options = struct {
|
||||||
power_preference: gpu.PowerPreference = .none,
|
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.
|
/// A Mach application.
|
||||||
///
|
///
|
||||||
/// The Context type is your own data type which can later be accessed via app.context from within
|
/// 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 {
|
pub fn init(allocator: std.mem.Allocator, context: Context, options: Options) !Self {
|
||||||
const backend_type = try util.detectBackendType(allocator);
|
const backend_type = try util.detectBackendType(allocator);
|
||||||
|
|
||||||
|
glfw.setErrorCallback(glfwErrorCallback);
|
||||||
try glfw.init(.{});
|
try glfw.init(.{});
|
||||||
|
|
||||||
// Create the test window and discover adapters using it (esp. for OpenGL)
|
// Create the test window and discover adapters using it (esp. for OpenGL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue