mach: Enable App.resize() and verify if all necessary functions are exported by App

This commit is contained in:
iddev5 2022-04-28 12:42:48 +05:30 committed by Stephen Gutekanst
parent 2aedc4ca01
commit 7598c2d7b8

View file

@ -166,6 +166,13 @@ fn init(allocator: Allocator, options: Options) !Engine {
}; };
} }
// TODO: check signatures
comptime {
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'");
}
pub fn main() !void { pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator(); const allocator = gpa.allocator();
@ -198,9 +205,9 @@ pub fn main() !void {
engine.gpu_driver.target_desc.height, engine.gpu_driver.target_desc.height,
); );
//if (funcs.resize) |f| { if (@hasDecl(App, "resize")) {
// try f(app, app.context, app.target_desc.width, app.target_desc.height); try app.resize(&engine, engine.gpu_driver.target_desc.width, engine.gpu_driver.target_desc.height);
//} }
engine.gpu_driver.current_desc = engine.gpu_driver.target_desc; engine.gpu_driver.current_desc = engine.gpu_driver.target_desc;
} }