glfw: use comptime magic to remove InternalUserPointer and associated overhead
This commit is contained in:
parent
8d2a4cd8d2
commit
6f32a338c0
5 changed files with 330 additions and 262 deletions
|
|
@ -53,9 +53,9 @@ pub inline fn makeContextCurrent(window: ?Window) error{ NoWindowContext, Platfo
|
|||
/// @thread_safety This function may be called from any thread.
|
||||
///
|
||||
/// see also: context_current, glfwMakeContextCurrent
|
||||
pub inline fn getCurrentContext() std.mem.Allocator.Error!?Window {
|
||||
pub inline fn getCurrentContext() ?Window {
|
||||
internal_debug.assertInitialized();
|
||||
if (c.glfwGetCurrentContext()) |handle| return try Window.from(handle);
|
||||
if (c.glfwGetCurrentContext()) |handle| return Window.from(handle);
|
||||
getError() catch |err| return switch (err) {
|
||||
Error.NotInitialized => unreachable,
|
||||
else => unreachable,
|
||||
|
|
@ -213,10 +213,7 @@ test "getCurrentContext" {
|
|||
try glfw.init(.{});
|
||||
defer glfw.terminate();
|
||||
|
||||
const current_context = glfw.getCurrentContext() catch |err| {
|
||||
std.debug.print("can't get current context, error={}\n", .{err});
|
||||
return;
|
||||
};
|
||||
const current_context = glfw.getCurrentContext();
|
||||
std.debug.assert(current_context == null);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue