glfw: un-hardcode constant
Make the constant extracted from GLFW source into `time.setTime`, into a better-documented set of comptime instructions
This commit is contained in:
parent
1d648c2256
commit
7b9b0469cb
1 changed files with 5 additions and 3 deletions
|
|
@ -58,9 +58,11 @@ pub inline fn setTime(time: f64) void {
|
|||
|
||||
std.debug.assert(!std.math.isNan(time));
|
||||
std.debug.assert(time >= 0);
|
||||
// TODO: Look into why GLFW uses this hardcoded float literal as the maximum valid value for 'time'.
|
||||
// Maybe propose upstream to name this constant.
|
||||
std.debug.assert(time <= 18446744073.0);
|
||||
// assert time is lteq to largest number of seconds representable by u64 with nanosecond precision
|
||||
std.debug.assert(time <= max_time: {
|
||||
const @"2^64" = std.math.maxInt(u64);
|
||||
break :max_time @divTrunc(@"2^64", std.time.ns_per_s);
|
||||
});
|
||||
|
||||
c.glfwSetTime(time);
|
||||
getError() catch |err| return switch (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue