gpu: make Device.setUncapturedErrorCallback friendlier
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
be402d4b6d
commit
6f2f7056b7
1 changed files with 9 additions and 3 deletions
|
|
@ -194,10 +194,16 @@ pub const Device = opaque {
|
|||
// TODO: presumably callback should be nullable for unsetting
|
||||
pub inline fn setUncapturedErrorCallback(
|
||||
device: *Device,
|
||||
callback: ErrorCallback,
|
||||
userdata: ?*anyopaque,
|
||||
comptime Context: type,
|
||||
comptime callback: fn (typ: ErrorType, message: [*:0]const u8, ctx: Context) callconv(.Inline) void,
|
||||
context: Context,
|
||||
) void {
|
||||
Impl.deviceSetUncapturedErrorCallback(device, callback, userdata);
|
||||
const Helper = struct {
|
||||
pub fn callback(typ: ErrorType, message: [*:0]const u8, userdata: ?*anyopaque) callconv(.C) void {
|
||||
callback(typ, message, if (Context == void) {} orelse @ptrCast(Context, userdata));
|
||||
}
|
||||
};
|
||||
Impl.deviceSetUncapturedErrorCallback(device, Helper.callback, if (Context == void) null orelse context);
|
||||
}
|
||||
|
||||
pub inline fn tick(device: *Device) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue