native: switch to setWaitEvent()
This commit is contained in:
parent
15c71f5135
commit
9354c178eb
2 changed files with 46 additions and 0 deletions
|
|
@ -53,10 +53,28 @@ pub fn setOptions(engine: *Engine, options: structs.Options) !void {
|
|||
engine.options = options;
|
||||
}
|
||||
|
||||
// Signals mach to stop the update loop.
|
||||
pub fn setShouldClose(engine: *Engine, value: bool) void {
|
||||
engine.internal.setShouldClose(value);
|
||||
}
|
||||
|
||||
// Signals mach to wait for an event with timeout before calling update()
|
||||
// again. Mach resets to null, so call during each update() if needed.
|
||||
//
|
||||
// timeout is in seconds (null disables waiting)
|
||||
// - pass std.math.floatMax(f64) to wait with no timeout
|
||||
//
|
||||
// update() can be called earlier than timeout if an event happens (key press,
|
||||
// mouse motion, etc.)
|
||||
//
|
||||
// update() can be called a bit later than timeout due to timer precision and
|
||||
// process scheduling.
|
||||
//
|
||||
// Calling this multiple times means the last call's value is used.
|
||||
pub fn setWaitEvent(engine: *Engine, timeout: ?f64) void {
|
||||
engine.internal.setWaitEvent(timeout);
|
||||
}
|
||||
|
||||
// Returns the framebuffer size, in subpixel units.
|
||||
//
|
||||
// e.g. returns 1280x960 on macOS for a window that is 640x480
|
||||
|
|
@ -71,6 +89,10 @@ pub fn getWindowSize(engine: *Engine) structs.Size {
|
|||
return engine.internal.getWindowSize();
|
||||
}
|
||||
|
||||
pub fn hasEvent(engine: *Engine) !bool {
|
||||
return engine.internal.hasEvent();
|
||||
}
|
||||
|
||||
pub fn pollEvent(engine: *Engine) ?structs.Event {
|
||||
return engine.internal.pollEvent();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue