From 441d8d7928b11a4c14637c453d6fb86838f8c094 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 18 Jul 2021 17:47:07 -0700 Subject: [PATCH] glfw: add Window.defaultHints Signed-off-by: Stephen Gutekanst --- glfw/src/Window.zig | 31 +++++++++++++++++++++++++++++++ glfw/src/main.zig | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 glfw/src/Window.zig diff --git a/glfw/src/Window.zig b/glfw/src/Window.zig new file mode 100644 index 00000000..1c6930ad --- /dev/null +++ b/glfw/src/Window.zig @@ -0,0 +1,31 @@ +//! Window type and related functions + +const std = @import("std"); +const c = @import("c.zig").c; + +const Error = @import("errors.zig").Error; +const getError = @import("errors.zig").getError; + +const Window = @This(); + +/// Resets all window hints to their default values. +/// +/// This function resets all window hints to their default values. +/// +/// Possible errors include glfw.Error.NotInitialized. +/// +/// @thread_safety This function must only be called from the main thread. +/// +/// see also: window_hints, glfw.Window.hint, glfw.Window.hintString +pub fn defaultHints() Error!void { + c.glfwDefaultWindowHints(); + try getError(); +} + +test "defaultHints" { + const glfw = @import("main.zig"); + try glfw.init(); + defer glfw.terminate(); + + try defaultHints(); +} diff --git a/glfw/src/main.zig b/glfw/src/main.zig index 88bff53a..4b0841f7 100644 --- a/glfw/src/main.zig +++ b/glfw/src/main.zig @@ -19,6 +19,7 @@ pub const Monitor = @import("Monitor.zig"); pub const mouse_button = @import("mouse_button.zig"); pub const version = @import("version.zig"); pub const VideoMode = @import("VideoMode.zig"); +pub const Window = @import("Window.zig"); /// Initializes the GLFW library. /// @@ -149,5 +150,6 @@ test "basic" { _ = Monitor; _ = GammaRamp; _ = VideoMode; + _ = Window; basicTest() catch unreachable; }