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:
Stephen Gutekanst 2022-11-06 15:02:55 -07:00
parent d2358e8edf
commit 25464e74ca

View file

@ -23,8 +23,8 @@ const Window = @This();
handle: *c.GLFWwindow,
/// Returns a Zig GLFW window from an underlying C GLFW window handle.
pub inline fn from(handle: *c.GLFWwindow) Window {
return Window{ .handle = handle };
pub inline fn from(handle: *anyopaque) Window {
return Window{ .handle = @ptrCast(*c.GLFWwindow, @alignCast(@alignOf(*c.GLFWwindow), handle)) };
}
/// Resets all window hints to their default values.