mach: Use math.inf instead of math.floatMax for indefinite wait of events
This commit is contained in:
parent
ff69efea52
commit
f80161bc72
2 changed files with 5 additions and 6 deletions
|
|
@ -62,7 +62,7 @@ pub fn setShouldClose(engine: *Engine, value: bool) void {
|
||||||
// again.
|
// again.
|
||||||
//
|
//
|
||||||
// timeout is in seconds (<= 0.0 disables waiting)
|
// timeout is in seconds (<= 0.0 disables waiting)
|
||||||
// - pass std.math.floatMax(f64) to wait with no timeout
|
// - pass std.math.inf(f64) to wait with no timeout
|
||||||
//
|
//
|
||||||
// update() can be called earlier than timeout if an event happens (key press,
|
// update() can be called earlier than timeout if an event happens (key press,
|
||||||
// mouse motion, etc.)
|
// mouse motion, etc.)
|
||||||
|
|
|
||||||
|
|
@ -556,16 +556,15 @@ pub fn main() !void {
|
||||||
const window = engine.internal.window;
|
const window = engine.internal.window;
|
||||||
while (!window.shouldClose()) {
|
while (!window.shouldClose()) {
|
||||||
if (engine.internal.wait_event_timeout > 0.0) {
|
if (engine.internal.wait_event_timeout > 0.0) {
|
||||||
// wait for an event
|
if (engine.internal.wait_event_timeout == std.math.inf(f64)) {
|
||||||
if (engine.internal.wait_event_timeout == std.math.floatMax(f64)) {
|
// Wait for an event
|
||||||
// no timeout
|
|
||||||
try glfw.waitEvents();
|
try glfw.waitEvents();
|
||||||
} else {
|
} else {
|
||||||
// with a timeout
|
// Wait for an event with a timeout
|
||||||
try glfw.waitEventsTimeout(engine.internal.wait_event_timeout);
|
try glfw.waitEventsTimeout(engine.internal.wait_event_timeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// don't wait
|
// Don't wait for events
|
||||||
try glfw.pollEvents();
|
try glfw.pollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue