diff --git a/examples/text/Game.zig b/examples/text/Game.zig index 7d4a9b4d..7442d6d4 100644 --- a/examples/text/Game.zig +++ b/examples/text/Game.zig @@ -39,6 +39,7 @@ pub const Mod = mach.Mod(@This()); pub const global_events = .{ .init = .{ .handler = init }, + .deinit = .{ .handler = deinit }, .tick = .{ .handler = tick }, }; @@ -56,6 +57,12 @@ const text1: []const []const u8 = &.{ const text2: []const []const u8 = &.{"$!?😊"}; +fn deinit( + text_pipeline: *gfx.TextPipeline.Mod, +) !void { + text_pipeline.send(.deinit, .{}); +} + fn init( core: *mach.Core.Mod, text: *gfx.Text.Mod, @@ -63,6 +70,8 @@ fn init( text_style: *gfx.TextStyle.Mod, game: *Mod, ) !void { + text_pipeline.send(.init, .{}); + // TODO: a better way to initialize entities with default values // TODO(text): most of these style options are not respected yet. const style1 = try core.newEntity(); diff --git a/src/gfx/TextPipeline.zig b/src/gfx/TextPipeline.zig index 4556f0e7..b220f882 100644 --- a/src/gfx/TextPipeline.zig +++ b/src/gfx/TextPipeline.zig @@ -60,11 +60,9 @@ pub const components = .{ .built = .{ .type = BuiltPipeline, .description = "internal" }, }; -pub const global_events = .{ - .deinit = .{ .handler = deinit }, -}; - pub const local_events = .{ + .init = .{ .handler = fn () void }, + .deinit = .{ .handler = deinit }, .update = .{ .handler = update }, .pre_render = .{ .handler = preRender }, .render = .{ .handler = render },