glfw: make Window attributes a proper enum
Helps hexops/mach#37 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
65d8d2d10f
commit
8df412ed90
2 changed files with 75 additions and 74 deletions
|
|
@ -1040,6 +1040,75 @@ pub inline fn setMonitor(self: Window, monitor: ?Monitor, xpos: isize, ypos: isi
|
|||
try getError();
|
||||
}
|
||||
|
||||
/// Window attributes
|
||||
pub const Attrib = enum(c_int) {
|
||||
/// Input focus window hit or window attribute.
|
||||
focused = c.GLFW_FOCUSED,
|
||||
|
||||
/// Window iconification window attribute.
|
||||
iconified = c.GLFW_ICONIFIED,
|
||||
|
||||
// Window resize-ability window attribute
|
||||
resizable = c.GLFW_RESIZABLE,
|
||||
|
||||
/// Window visibility window attribute
|
||||
visible = c.GLFW_VISIBLE,
|
||||
|
||||
/// Window decoration window attribute
|
||||
decorated = c.GLFW_DECORATED,
|
||||
|
||||
/// Window auto-iconification window attribute
|
||||
auto_iconify = c.GLFW_AUTO_ICONIFY,
|
||||
|
||||
/// Window decoration window attribute
|
||||
floating = c.GLFW_FLOATING,
|
||||
|
||||
/// Window maximization window attribute
|
||||
maximized = c.GLFW_MAXIMIZED,
|
||||
|
||||
/// Window framebuffer transparency attribute
|
||||
transparent_framebuffer = c.GLFW_TRANSPARENT_FRAMEBUFFER,
|
||||
|
||||
/// Mouse cursor hover window attribute.
|
||||
hovered = c.GLFW_HOVERED,
|
||||
|
||||
/// Input focus on calling show window attribute
|
||||
focus_on_show = c.GLFW_FOCUS_ON_SHOW,
|
||||
|
||||
/// Context client API attribute.
|
||||
client_api = c.GLFW_CLIENT_API,
|
||||
|
||||
/// Context client API major version attribute.
|
||||
context_version_major = c.GLFW_CONTEXT_VERSION_MAJOR,
|
||||
|
||||
/// Context client API minor version attribute.
|
||||
context_version_minor = c.GLFW_CONTEXT_VERSION_MINOR,
|
||||
|
||||
/// Context client API revision number attribute.
|
||||
context_revision = c.GLFW_CONTEXT_REVISION,
|
||||
|
||||
/// Context robustness attribute.
|
||||
context_robustness = c.GLFW_CONTEXT_ROBUSTNESS,
|
||||
|
||||
/// OpenGL forward-compatibility attribute.
|
||||
opengl_forward_compat = c.GLFW_OPENGL_FORWARD_COMPAT,
|
||||
|
||||
/// Debug mode context attribute.
|
||||
opengl_debug_context = c.GLFW_OPENGL_DEBUG_CONTEXT,
|
||||
|
||||
/// OpenGL profile attribute.
|
||||
opengl_profile = c.GLFW_OPENGL_PROFILE,
|
||||
|
||||
/// Context flush-on-release attribute.
|
||||
context_release_behavior = c.GLFW_CONTEXT_RELEASE_BEHAVIOR,
|
||||
|
||||
/// Context error suppression attribute.
|
||||
context_no_error = c.GLFW_CONTEXT_NO_ERROR,
|
||||
|
||||
/// Context creation API attribute.
|
||||
context_creation_api = c.GLFW_CONTEXT_CREATION_API,
|
||||
};
|
||||
|
||||
/// Returns an attribute of the specified window.
|
||||
///
|
||||
/// This function returns the value of an attribute of the specified window or its OpenGL or OpenGL
|
||||
|
|
@ -1059,8 +1128,8 @@ pub inline fn setMonitor(self: Window, monitor: ?Monitor, xpos: isize, ypos: isi
|
|||
/// @thread_safety This function must only be called from the main thread.
|
||||
///
|
||||
/// see also: window_attribs, glfw.Window.setAttrib
|
||||
pub inline fn getAttrib(self: Window, attrib: isize) Error!isize {
|
||||
const v = c.glfwGetWindowAttrib(self.handle, @intCast(c_int, attrib));
|
||||
pub inline fn getAttrib(self: Window, attrib: Attrib) Error!isize {
|
||||
const v = c.glfwGetWindowAttrib(self.handle, @enumToInt(attrib));
|
||||
try getError();
|
||||
return v;
|
||||
}
|
||||
|
|
@ -1089,8 +1158,8 @@ pub inline fn getAttrib(self: Window, attrib: isize) Error!isize {
|
|||
///
|
||||
/// see also: window_attribs, glfw.Window.getAttrib
|
||||
///
|
||||
pub inline fn setAttrib(self: Window, attrib: isize, value: bool) Error!void {
|
||||
c.glfwSetWindowAttrib(self.handle, @intCast(c_int, attrib), if (value) c.GLFW_TRUE else c.GLFW_FALSE);
|
||||
pub inline fn setAttrib(self: Window, attrib: Attrib, value: bool) Error!void {
|
||||
c.glfwSetWindowAttrib(self.handle, @enumToInt(attrib), if (value) c.GLFW_TRUE else c.GLFW_FALSE);
|
||||
try getError();
|
||||
}
|
||||
|
||||
|
|
@ -2424,7 +2493,7 @@ test "getAttrib" {
|
|||
};
|
||||
defer window.destroy();
|
||||
|
||||
_ = window.getAttrib(glfw.focused) catch |err| std.debug.print("can't check if window is focused, not supported by OS maybe? error={}\n", .{err});
|
||||
_ = window.getAttrib(.focused) catch |err| std.debug.print("can't check if window is focused, not supported by OS maybe? error={}\n", .{err});
|
||||
}
|
||||
|
||||
test "setAttrib" {
|
||||
|
|
@ -2440,7 +2509,7 @@ test "setAttrib" {
|
|||
};
|
||||
defer window.destroy();
|
||||
|
||||
window.setAttrib(glfw.decorated, false) catch |err| std.debug.print("can't remove window decorations, not supported by OS maybe? error={}\n", .{err});
|
||||
window.setAttrib(.decorated, false) catch |err| std.debug.print("can't remove window decorations, not supported by OS maybe? error={}\n", .{err});
|
||||
}
|
||||
|
||||
test "setUserPointer" {
|
||||
|
|
|
|||
|
|
@ -2,74 +2,6 @@
|
|||
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
// Input focus window attribute
|
||||
|
||||
/// Input focus window hit or window attribute.
|
||||
pub const focused = c.GLFW_FOCUSED;
|
||||
|
||||
/// Window iconification window attribute.
|
||||
pub const iconified = c.GLFW_ICONIFIED;
|
||||
|
||||
// Window resize-ability window attribute
|
||||
pub const resizable = c.GLFW_RESIZABLE;
|
||||
|
||||
/// Window visibility window attribute
|
||||
pub const visible = c.GLFW_VISIBLE;
|
||||
|
||||
/// Window decoration window attribute
|
||||
pub const decorated = c.GLFW_DECORATED;
|
||||
|
||||
/// Window auto-iconification window attribute
|
||||
pub const auto_iconify = c.GLFW_AUTO_ICONIFY;
|
||||
|
||||
/// Window decoration window attribute
|
||||
pub const floating = c.GLFW_FLOATING;
|
||||
|
||||
/// Window maximization window attribute
|
||||
pub const maximized = c.GLFW_MAXIMIZED;
|
||||
|
||||
/// Window framebuffer transparency attribute
|
||||
pub const transparent_framebuffer = c.GLFW_TRANSPARENT_FRAMEBUFFER;
|
||||
|
||||
/// Mouse cursor hover window attribute.
|
||||
pub const hovered = c.GLFW_HOVERED;
|
||||
|
||||
/// Input focus on calling show window attribute
|
||||
pub const focus_on_show = c.GLFW_FOCUS_ON_SHOW;
|
||||
|
||||
/// Context client API attribute.
|
||||
pub const client_api = c.GLFW_CLIENT_API;
|
||||
|
||||
/// Context client API major version attribute.
|
||||
pub const context_version_major = c.GLFW_CONTEXT_VERSION_MAJOR;
|
||||
|
||||
/// Context client API minor version attribute.
|
||||
pub const context_version_minor = c.GLFW_CONTEXT_VERSION_MINOR;
|
||||
|
||||
/// Context client API revision number attribute.
|
||||
pub const context_revision = c.GLFW_CONTEXT_REVISION;
|
||||
|
||||
/// Context robustness attribute.
|
||||
pub const context_robustness = c.GLFW_CONTEXT_ROBUSTNESS;
|
||||
|
||||
/// OpenGL forward-compatibility attribute.
|
||||
pub const opengl_forward_compat = c.GLFW_OPENGL_FORWARD_COMPAT;
|
||||
|
||||
/// Debug mode context attribute.
|
||||
pub const opengl_debug_context = c.GLFW_OPENGL_DEBUG_CONTEXT;
|
||||
|
||||
/// OpenGL profile attribute.
|
||||
pub const opengl_profile = c.GLFW_OPENGL_PROFILE;
|
||||
|
||||
/// Context flush-on-release attribute.
|
||||
pub const context_release_behavior = c.GLFW_CONTEXT_RELEASE_BEHAVIOR;
|
||||
|
||||
/// Context error suppression attribute.
|
||||
pub const context_no_error = c.GLFW_CONTEXT_NO_ERROR;
|
||||
|
||||
/// Context creation API attribute.
|
||||
pub const context_creation_api = c.GLFW_CONTEXT_CREATION_API;
|
||||
|
||||
/// Window content area scaling window
|
||||
pub const scale_to_monitor = c.GLFW_SCALE_TO_MONITOR;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue