glfw: ensure Window.from handle is untyped
Since users of the library do not have access to the `@cImport` struct (and we do not want to expose that), the user may pass only an untyped `*anyopaque` pointer which we'll internally cast to `*c.GLFWwindow`. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
d2358e8edf
commit
25464e74ca
1 changed files with 2 additions and 2 deletions
|
@ -23,8 +23,8 @@ const Window = @This();
|
||||||
handle: *c.GLFWwindow,
|
handle: *c.GLFWwindow,
|
||||||
|
|
||||||
/// Returns a Zig GLFW window from an underlying C GLFW window handle.
|
/// Returns a Zig GLFW window from an underlying C GLFW window handle.
|
||||||
pub inline fn from(handle: *c.GLFWwindow) Window {
|
pub inline fn from(handle: *anyopaque) Window {
|
||||||
return Window{ .handle = handle };
|
return Window{ .handle = @ptrCast(*c.GLFWwindow, @alignCast(@alignOf(*c.GLFWwindow), handle)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets all window hints to their default values.
|
/// Resets all window hints to their default values.
|
||||||
|
|
Loading…
Add table
Reference in a new issue