mach: App.update will now return !void instead of !bool

In order to close the application, there is already
Engine.setShouldClose() which would roughly do the same thing.
This commit is contained in:
iddev5 2022-06-08 12:44:27 +05:30 committed by Stephen Gutekanst
parent 3234b6c0dd
commit 40c0659cc9
4 changed files with 6 additions and 9 deletions

View file

@ -2,5 +2,5 @@ pub fn checkApplication(comptime App: type) void {
// TODO: check signature
if (!@hasDecl(App, "init")) @compileError("App must export 'pub fn init(app: *App, engine: *mach.Engine) !void'");
if (!@hasDecl(App, "deinit")) @compileError("App must export 'pub fn deinit(app: *App, engine: *mach.Engine) void'");
if (!@hasDecl(App, "update")) @compileError("App must export 'pub fn update(app: *App, engine: *mach.Engine) !bool'");
if (!@hasDecl(App, "update")) @compileError("App must export 'pub fn update(app: *App, engine: *mach.Engine) !void'");
}

View file

@ -511,8 +511,6 @@ pub fn main() !void {
engine.current_desc = engine.target_desc;
}
const success = try app.update(&engine);
if (!success)
break;
try app.update(&engine);
}
}

View file

@ -196,14 +196,14 @@ export fn wasmInit() void {
app.init(&engine) catch {};
}
export fn wasmUpdate() bool {
export fn wasmUpdate() void {
// Poll internal events, like resize
engine.internal.pollChanges();
engine.delta_time_ns = engine.timer.lapPrecise();
engine.delta_time = @intToFloat(f32, engine.delta_time_ns) / @intToFloat(f32, std.time.ns_per_s);
return app.update(&engine) catch false;
app.update(&engine) catch engine.setShouldClose(true);
}
export fn wasmDeinit() void {