glfw: replace glfw.dont_care as sentinel value
Also change logic inside `Hints.set` to account for this special case
This commit is contained in:
parent
f906bd6c79
commit
4252ee0b1f
1 changed files with 16 additions and 12 deletions
|
|
@ -189,7 +189,7 @@ pub const Hints = struct {
|
||||||
samples: c_int = 0,
|
samples: c_int = 0,
|
||||||
|
|
||||||
/// Monitor refresh rate
|
/// Monitor refresh rate
|
||||||
refresh_rate: c_int = glfw.dont_care,
|
refresh_rate: ?std.math.IntFittingRange(0, std.math.maxInt(c_int)) = null,
|
||||||
|
|
||||||
/// OpenGL stereoscopic rendering
|
/// OpenGL stereoscopic rendering
|
||||||
stereo: bool = false,
|
stereo: bool = false,
|
||||||
|
|
@ -268,22 +268,26 @@ pub const Hints = struct {
|
||||||
inline for (comptime std.meta.fieldNames(Hint)) |field_name| {
|
inline for (comptime std.meta.fieldNames(Hint)) |field_name| {
|
||||||
const hint_tag = @enumToInt(@field(Hint, field_name));
|
const hint_tag = @enumToInt(@field(Hint, field_name));
|
||||||
const hint_value = @field(hints, field_name);
|
const hint_value = @field(hints, field_name);
|
||||||
switch (@TypeOf(hint_value)) {
|
switch (@field(Hint, field_name)) {
|
||||||
bool => c.glfwWindowHint(hint_tag, @boolToInt(hint_value)),
|
.refresh_rate => c.glfwWindowHint(hint_tag, if (hint_value) |refresh_rate| refresh_rate else glfw.dont_care),
|
||||||
c_int => c.glfwWindowHint(hint_tag, hint_value),
|
else => switch (@TypeOf(hint_value)) {
|
||||||
|
bool => c.glfwWindowHint(hint_tag, @boolToInt(hint_value)),
|
||||||
|
c_int => c.glfwWindowHint(hint_tag, hint_value),
|
||||||
|
|
||||||
ClientAPI,
|
ClientAPI,
|
||||||
ContextCreationAPI,
|
ContextCreationAPI,
|
||||||
ContextRobustness,
|
ContextRobustness,
|
||||||
ContextReleaseBehavior,
|
ContextReleaseBehavior,
|
||||||
OpenGLProfile,
|
OpenGLProfile,
|
||||||
=> c.glfwWindowHint(hint_tag, @enumToInt(hint_value)),
|
=> c.glfwWindowHint(hint_tag, @enumToInt(hint_value)),
|
||||||
|
|
||||||
[:0]const u8 => c.glfwWindowHintString(hint_tag, hint_value.ptr),
|
[:0]const u8 => c.glfwWindowHintString(hint_tag, hint_value.ptr),
|
||||||
|
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getError() catch |err| return switch (err) {
|
getError() catch |err| return switch (err) {
|
||||||
Error.NotInitialized => unreachable,
|
Error.NotInitialized => unreachable,
|
||||||
Error.InvalidEnum => unreachable,
|
Error.InvalidEnum => unreachable,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue