diff --git a/glfw/src/Window.zig b/glfw/src/Window.zig index 1c6930ad..9dbb2de1 100644 --- a/glfw/src/Window.zig +++ b/glfw/src/Window.zig @@ -22,6 +22,31 @@ pub fn defaultHints() Error!void { try getError(); } +/// Sets the specified window hint to the desired value. +/// +/// This function sets hints for the next call to glfw.Window.create. The hints, once set, retain +/// their values until changed by a call to this function or glfw.window.defaultHints, or until the +/// library is terminated. +/// +/// Only integer value hints can be set with this function. String value hints are set with +/// glfw.Window.hintString. +/// +/// This function does not check whether the specified hint values are valid. If you set hints to +/// invalid values this will instead be reported by the next call to glfw.createWindow. +/// +/// Some hints are platform specific. These may be set on any platform but they will only affect +/// their specific platform. Other platforms will ignore them. +/// +/// Possible errors include glfw.Error.NotInitialized and glfw.Error.InvalidEnum. +/// +/// @thread_safety This function must only be called from the main thread. +/// +/// see also: window_hints, glfw.Window.hintString, glfw.Window.defaultHints +pub fn hint(hint_const: usize, value: isize) Error!void { + c.glfwWindowHint(@intCast(c_int, hint_const), @intCast(c_int, value)); + try getError(); +} + test "defaultHints" { const glfw = @import("main.zig"); try glfw.init(); @@ -29,3 +54,12 @@ test "defaultHints" { try defaultHints(); } + +test "hint" { + const glfw = @import("main.zig"); + try glfw.init(); + defer glfw.terminate(); + + try hint(glfw.focused, 1); + try defaultHints(); +}