Core: use .app local init/deinit/tick events (avoid global events)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
fb37f74d41
commit
2c8ba82aa3
9 changed files with 41 additions and 48 deletions
|
|
@ -5,14 +5,20 @@ const gpu = mach.gpu;
|
|||
pub const name = .app;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub const global_events = .{
|
||||
pub const local_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
title_timer: mach.Timer,
|
||||
pipeline: *gpu.RenderPipeline,
|
||||
|
||||
pub fn deinit(core: *mach.Core.Mod, game: *Mod) void {
|
||||
game.state().pipeline.release();
|
||||
core.send(.deinit, .{});
|
||||
}
|
||||
|
||||
fn init(game: *Mod, core: *mach.Core.Mod) !void {
|
||||
// Create our shader module
|
||||
const shader_module = core.state().device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl"));
|
||||
|
|
@ -54,10 +60,6 @@ fn init(game: *Mod, core: *mach.Core.Mod) !void {
|
|||
try updateWindowTitle(core);
|
||||
}
|
||||
|
||||
pub fn deinit(game: *Mod) void {
|
||||
game.state().pipeline.release();
|
||||
}
|
||||
|
||||
// TODO(important): remove need for returning an error here
|
||||
fn tick(core: *mach.Core.Mod, game: *Mod) !void {
|
||||
// TODO(important): event polling should occur in mach.Core module and get fired as ECS event.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue