From 80be6b7bca6e210c0e96ebbcc31f6182c491ee2c Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 24 Aug 2024 17:05:21 -0700 Subject: [PATCH] examples: revert to 0.4 entrypoint / control API design Signed-off-by: Stephen Gutekanst --- examples/core/custom-entrypoint/App.zig | 20 ++++++++++++++------ examples/core/custom-entrypoint/main.zig | 1 - examples/core/triangle/App.zig | 22 ++++++++++++++++------ examples/core/triangle/main.zig | 1 - examples/custom-renderer/App.zig | 14 ++++++++------ examples/custom-renderer/Renderer.zig | 11 +++++------ examples/custom-renderer/main.zig | 5 ++--- examples/glyphs/App.zig | 15 ++++++++++----- examples/glyphs/Glyphs.zig | 2 +- examples/glyphs/main.zig | 1 - examples/hardware-check/App.zig | 10 ++++++++-- examples/hardware-check/main.zig | 1 - examples/piano/App.zig | 13 +++++++++---- examples/piano/main.zig | 1 - examples/play-opus/App.zig | 12 +++++++++--- examples/play-opus/main.zig | 1 - examples/sprite/App.zig | 12 ++++++++++-- examples/sprite/main.zig | 1 - examples/text/App.zig | 17 +++++++++++++---- examples/text/main.zig | 1 - 20 files changed, 105 insertions(+), 56 deletions(-) diff --git a/examples/core/custom-entrypoint/App.zig b/examples/core/custom-entrypoint/App.zig index 0585db2b..9ac6c19b 100644 --- a/examples/core/custom-entrypoint/App.zig +++ b/examples/core/custom-entrypoint/App.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); const gpu = mach.gpu; @@ -7,18 +6,25 @@ pub const Mod = mach.Mod(@This()); pub const systems = .{ .init = .{ .handler = init }, + .after_init = .{ .handler = afterInit }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, }; title_timer: mach.Timer, pipeline: *gpu.RenderPipeline, -pub fn deinit(game: *Mod) void { +pub fn deinit(core: *mach.Core.Mod, game: *Mod) void { game.state().pipeline.release(); + core.schedule(.deinit); } fn init(game: *Mod, core: *mach.Core.Mod) !void { + core.schedule(.init); + game.schedule(.after_init); +} + +fn afterInit(game: *Mod, core: *mach.Core.Mod) !void { // Create our shader module const shader_module = core.state().device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl")); defer shader_module.release(); @@ -57,11 +63,11 @@ fn init(game: *Mod, core: *mach.Core.Mod) !void { .pipeline = pipeline, }); try updateWindowTitle(core); + + core.schedule(.start); } -fn update(core: *mach.Core.Mod, game: *Mod) !void { - // TODO(important): event polling should occur in mach.Core module and get fired as ECS event. - // TODO(Core) +fn tick(core: *mach.Core.Mod, game: *Mod) !void { var iter = core.state().pollEvents(); while (iter.next()) |event| { switch (event) { @@ -106,6 +112,7 @@ fn update(core: *mach.Core.Mod, game: *Mod) !void { defer command.release(); core.state().queue.submit(&[_]*gpu.CommandBuffer{command}); + // Present the frame core.schedule(.present_frame); // update the window title every second @@ -125,4 +132,5 @@ fn updateWindowTitle(core: *mach.Core.Mod) !void { core.state().inputRate(), }, ); + core.schedule(.update); } diff --git a/examples/core/custom-entrypoint/main.zig b/examples/core/custom-entrypoint/main.zig index 47bcd433..0a44b180 100644 --- a/examples/core/custom-entrypoint/main.zig +++ b/examples/core/custom-entrypoint/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/core/triangle/App.zig b/examples/core/triangle/App.zig index b422c7fd..9ac6c19b 100644 --- a/examples/core/triangle/App.zig +++ b/examples/core/triangle/App.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); const gpu = mach.gpu; @@ -7,18 +6,25 @@ pub const Mod = mach.Mod(@This()); pub const systems = .{ .init = .{ .handler = init }, + .after_init = .{ .handler = afterInit }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, }; title_timer: mach.Timer, pipeline: *gpu.RenderPipeline, -pub fn deinit(game: *Mod) void { +pub fn deinit(core: *mach.Core.Mod, game: *Mod) void { game.state().pipeline.release(); + core.schedule(.deinit); } fn init(game: *Mod, core: *mach.Core.Mod) !void { + core.schedule(.init); + game.schedule(.after_init); +} + +fn afterInit(game: *Mod, core: *mach.Core.Mod) !void { // Create our shader module const shader_module = core.state().device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl")); defer shader_module.release(); @@ -56,10 +62,12 @@ fn init(game: *Mod, core: *mach.Core.Mod) !void { .title_timer = try mach.Timer.start(), .pipeline = pipeline, }); - // try updateWindowTitle(core); + try updateWindowTitle(core); + + core.schedule(.start); } -fn update(core: *mach.Core.Mod, game: *Mod) !void { +fn tick(core: *mach.Core.Mod, game: *Mod) !void { var iter = core.state().pollEvents(); while (iter.next()) |event| { switch (event) { @@ -74,7 +82,7 @@ fn update(core: *mach.Core.Mod, game: *Mod) !void { defer back_buffer_view.release(); // Create a command encoder - const label = @tagName(name) ++ ".update"; + const label = @tagName(name) ++ ".tick"; const encoder = core.state().device.createCommandEncoder(&.{ .label = label }); defer encoder.release(); @@ -104,6 +112,7 @@ fn update(core: *mach.Core.Mod, game: *Mod) !void { defer command.release(); core.state().queue.submit(&[_]*gpu.CommandBuffer{command}); + // Present the frame core.schedule(.present_frame); // update the window title every second @@ -123,4 +132,5 @@ fn updateWindowTitle(core: *mach.Core.Mod) !void { core.state().inputRate(), }, ); + core.schedule(.update); } diff --git a/examples/core/triangle/main.zig b/examples/core/triangle/main.zig index 47bcd433..0a44b180 100644 --- a/examples/core/triangle/main.zig +++ b/examples/core/triangle/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/custom-renderer/App.zig b/examples/custom-renderer/App.zig index ff1d7266..24cd8288 100644 --- a/examples/custom-renderer/App.zig +++ b/examples/custom-renderer/App.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); const math = mach.math; const Renderer = @import("Renderer.zig"); @@ -25,7 +24,7 @@ pub const components = .{ pub const systems = .{ .init = .{ .handler = init }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, }; // Define the globally unique name of our module. You can use any name here, but keep in mind no @@ -38,8 +37,9 @@ pub const name = .app; // Note that Mod.state() returns an instance of our module struct. pub const Mod = mach.Mod(@This()); -pub fn deinit(renderer: *Renderer.Mod) void { +pub fn deinit(core: *mach.Core.Mod, renderer: *Renderer.Mod) void { renderer.schedule(.deinit); + core.schedule(.deinit); } fn init( @@ -47,9 +47,11 @@ fn init( // of the program we can have these types injected here, letting us work with other modules in // our program seamlessly and with a type-safe API: entities: *mach.Entities.Mod, + core: *mach.Core.Mod, renderer: *Renderer.Mod, game: *Mod, ) !void { + core.schedule(.init); renderer.schedule(.init); // Create our player entity. @@ -73,16 +75,16 @@ fn init( .spawn_timer = try mach.Timer.start(), .player = player, }); + + core.schedule(.start); } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, renderer: *Renderer.Mod, game: *Mod, ) !void { - // TODO(important): event polling should occur in mach.Core module and get fired as ECS event. - // TODO(Core) var iter = core.state().pollEvents(); var direction = game.state().direction; var spawning = game.state().spawning; diff --git a/examples/custom-renderer/Renderer.zig b/examples/custom-renderer/Renderer.zig index 61a72df6..89b0555a 100644 --- a/examples/custom-renderer/Renderer.zig +++ b/examples/custom-renderer/Renderer.zig @@ -1,7 +1,3 @@ -// TODO(important): docs -// TODO(important): review all code in this file in-depth -const std = @import("std"); - const mach = @import("mach"); const gpu = mach.gpu; const math = mach.math; @@ -110,7 +106,9 @@ fn init( }); } -fn deinit(renderer: *Mod) !void { +fn deinit( + renderer: *Mod, +) !void { renderer.state().pipeline.release(); for (renderer.state().bind_groups) |bind_group| bind_group.release(); renderer.state().uniform_buffer.release(); @@ -127,7 +125,7 @@ fn renderFrame( defer back_buffer_view.release(); // Create a command encoder - const label = @tagName(name) ++ ".renderFrame"; + const label = @tagName(name) ++ ".tick"; const encoder = core.state().device.createCommandEncoder(&.{ .label = label }); defer encoder.release(); @@ -177,5 +175,6 @@ fn renderFrame( defer command.release(); core.state().queue.submit(&[_]*gpu.CommandBuffer{command}); + // Present the frame core.schedule(.present_frame); } diff --git a/examples/custom-renderer/main.zig b/examples/custom-renderer/main.zig index 6425f980..b727c5a7 100644 --- a/examples/custom-renderer/main.zig +++ b/examples/custom-renderer/main.zig @@ -1,5 +1,3 @@ -const std = @import("std"); - const mach = @import("mach"); // The global list of Mach modules registered for use in our application. @@ -9,8 +7,9 @@ pub const modules = .{ @import("Renderer.zig"), }; +// TODO: move this to a mach "entrypoint" zig module pub fn main() !void { - // Initialize mach.Core + // Initialize mach core try mach.core.initModule(); // Main loop diff --git a/examples/glyphs/App.zig b/examples/glyphs/App.zig index 9008bf37..55537d8f 100644 --- a/examples/glyphs/App.zig +++ b/examples/glyphs/App.zig @@ -1,4 +1,3 @@ -// TODO(important): review all code in this file in-depth const std = @import("std"); const mach = @import("mach"); const gpu = mach.gpu; @@ -35,17 +34,19 @@ pub const Mod = mach.Mod(@This()); pub const systems = .{ .init = .{ .handler = init }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, .after_init = .{ .handler = afterInit }, .end_frame = .{ .handler = endFrame }, }; -fn deinit(sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod) !void { +fn deinit(core: *mach.Core.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod) !void { sprite_pipeline.schedule(.deinit); glyphs.schedule(.deinit); + core.schedule(.deinit); } -fn init(sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod, game: *Mod) !void { +fn init(core: *mach.Core.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod, game: *Mod) !void { + core.schedule(.init); sprite_pipeline.schedule(.init); glyphs.schedule(.init); @@ -62,6 +63,7 @@ fn afterInit( sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod, game: *Mod, + core: *mach.Core.Mod, ) !void { // Create a sprite rendering pipeline const texture = glyphs.state().texture; @@ -93,9 +95,11 @@ fn afterInit( .time = 0, .pipeline = pipeline, }); + + core.schedule(.start); } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, sprite: *gfx.Sprite.Mod, @@ -253,6 +257,7 @@ fn endFrame(game: *Mod, core: *mach.Core.Mod) !void { "glyphs [ FPS: {d} ] [ Sprites: {d} ]", .{ game.state().frame_count, game.state().sprites }, ); + core.schedule(.update); game.state().fps_timer.reset(); game.state().frame_count = 0; } diff --git a/examples/glyphs/Glyphs.zig b/examples/glyphs/Glyphs.zig index 65c29d4f..f693f4c4 100644 --- a/examples/glyphs/Glyphs.zig +++ b/examples/glyphs/Glyphs.zig @@ -1,4 +1,3 @@ -// TODO(important): review all code in this file in-depth const mach = @import("mach"); const gpu = mach.gpu; const ft = @import("freetype"); @@ -16,6 +15,7 @@ pub const systems = .{ const RegionMap = std.AutoArrayHashMapUnmanaged(u21, mach.gfx.Atlas.Region); +// TODO: banish global allocator var gpa = std.heap.GeneralPurposeAllocator(.{}){}; texture_atlas: mach.gfx.Atlas, diff --git a/examples/glyphs/main.zig b/examples/glyphs/main.zig index 1caa73c4..f45e71d7 100644 --- a/examples/glyphs/main.zig +++ b/examples/glyphs/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/hardware-check/App.zig b/examples/hardware-check/App.zig index b2e40532..e833b73e 100644 --- a/examples/hardware-check/App.zig +++ b/examples/hardware-check/App.zig @@ -15,6 +15,7 @@ const Vec3 = math.Vec3; const Mat3x3 = math.Mat3x3; const Mat4x4 = math.Mat4x4; +// TODO: banish global allocator var gpa = std.heap.GeneralPurposeAllocator(.{}){}; info_text: mach.EntityID, @@ -44,18 +45,20 @@ pub const systems = .{ .init = .{ .handler = init }, .after_init = .{ .handler = afterInit }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, .end_frame = .{ .handler = endFrame }, .audio_state_change = .{ .handler = audioStateChange }, }; fn deinit( + core: *mach.Core.Mod, text_pipeline: *gfx.TextPipeline.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod, audio: *mach.Audio.Mod, ) !void { text_pipeline.schedule(.deinit); sprite_pipeline.schedule(.deinit); + core.schedule(.deinit); audio.schedule(.deinit); } @@ -64,11 +67,13 @@ fn init( text_pipeline: *gfx.TextPipeline.Mod, text: *gfx.Text.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod, + core: *mach.Core.Mod, game: *Mod, ) !void { // If you want to try fullscreen: // try core.set(core.state().main_window, .fullscreen, true); + core.schedule(.init); audio.schedule(.init); text.schedule(.init); text_pipeline.schedule(.init); @@ -146,6 +151,7 @@ fn afterInit( .pipeline = pipeline, .sfx = sfx, }); + core.schedule(.start); } fn audioStateChange(entities: *mach.Entities.Mod) !void { @@ -164,7 +170,7 @@ fn audioStateChange(entities: *mach.Entities.Mod) !void { } } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, sprite: *gfx.Sprite.Mod, diff --git a/examples/hardware-check/main.zig b/examples/hardware-check/main.zig index 48b09aa6..605a803e 100644 --- a/examples/hardware-check/main.zig +++ b/examples/hardware-check/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/piano/App.zig b/examples/piano/App.zig index 329819b1..e83cbbe5 100644 --- a/examples/piano/App.zig +++ b/examples/piano/App.zig @@ -18,6 +18,7 @@ const sysaudio = mach.sysaudio; pub const App = @This(); +// TODO: banish global allocator var gpa = std.heap.GeneralPurposeAllocator(.{}){}; pub const name = .app; @@ -27,7 +28,7 @@ pub const systems = .{ .init = .{ .handler = init }, .after_init = .{ .handler = afterInit }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, .audio_state_change = .{ .handler = audioStateChange }, }; @@ -37,7 +38,8 @@ pub const components = .{ ghost_key_mode: bool = false, -fn init(audio: *mach.Audio.Mod, app: *Mod) void { +fn init(core: *mach.Core.Mod, audio: *mach.Audio.Mod, app: *Mod) void { + core.schedule(.init); audio.schedule(.init); app.schedule(.after_init); @@ -49,6 +51,8 @@ fn init(audio: *mach.Audio.Mod, app: *Mod) void { std.debug.print("[spacebar] enable ghost-key mode (demonstrate seamless back-to-back sound playback)\n", .{}); std.debug.print("[arrow up] increase volume 10%\n", .{}); std.debug.print("[arrow down] decrease volume 10%\n", .{}); + + core.schedule(.start); } fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void { @@ -57,8 +61,9 @@ fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void { audio.state().on_state_change = app.system(.audio_state_change); } -fn deinit(audio: *mach.Audio.Mod) void { +fn deinit(core: *mach.Core.Mod, audio: *mach.Audio.Mod) void { audio.schedule(.deinit); + core.schedule(.deinit); } fn audioStateChange( @@ -90,7 +95,7 @@ fn audioStateChange( } } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, audio: *mach.Audio.Mod, diff --git a/examples/piano/main.zig b/examples/piano/main.zig index ee27f081..17065b6b 100644 --- a/examples/piano/main.zig +++ b/examples/piano/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/play-opus/App.zig b/examples/play-opus/App.zig index c5974225..9d478430 100644 --- a/examples/play-opus/App.zig +++ b/examples/play-opus/App.zig @@ -12,6 +12,7 @@ const sysaudio = mach.sysaudio; pub const App = @This(); +// TODO: banish global allocator var gpa = std.heap.GeneralPurposeAllocator(.{}){}; pub const name = .app; @@ -21,7 +22,7 @@ pub const systems = .{ .init = .{ .handler = init }, .after_init = .{ .handler = afterInit }, .deinit = .{ .handler = deinit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, .audio_state_change = .{ .handler = audioStateChange }, }; @@ -33,9 +34,11 @@ sfx: mach.Audio.Opus, fn init( entities: *mach.Entities.Mod, + core: *mach.Core.Mod, audio: *mach.Audio.Mod, app: *Mod, ) !void { + core.schedule(.init); audio.schedule(.init); app.schedule(.after_init); @@ -61,6 +64,8 @@ fn init( std.debug.print("[typing] Play SFX\n", .{}); std.debug.print("[arrow up] increase volume 10%\n", .{}); std.debug.print("[arrow down] decrease volume 10%\n", .{}); + + core.schedule(.start); } fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void { @@ -69,8 +74,9 @@ fn afterInit(audio: *mach.Audio.Mod, app: *Mod) void { audio.state().on_state_change = app.system(.audio_state_change); } -fn deinit(audio: *mach.Audio.Mod) void { +fn deinit(core: *mach.Core.Mod, audio: *mach.Audio.Mod) void { audio.schedule(.deinit); + core.schedule(.deinit); } fn audioStateChange( @@ -99,7 +105,7 @@ fn audioStateChange( } } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, audio: *mach.Audio.Mod, diff --git a/examples/play-opus/main.zig b/examples/play-opus/main.zig index ee27f081..17065b6b 100644 --- a/examples/play-opus/main.zig +++ b/examples/play-opus/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/sprite/App.zig b/examples/sprite/App.zig index ea1b38d8..4713e91c 100644 --- a/examples/sprite/App.zig +++ b/examples/sprite/App.zig @@ -14,6 +14,7 @@ const Vec3 = math.Vec3; const Mat3x3 = math.Mat3x3; const Mat4x4 = math.Mat4x4; +// TODO: banish global allocator var gpa = std.heap.GeneralPurposeAllocator(.{}){}; timer: mach.Timer, @@ -40,20 +41,24 @@ pub const systems = .{ .init = .{ .handler = init }, .deinit = .{ .handler = deinit }, .after_init = .{ .handler = afterInit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, .end_frame = .{ .handler = endFrame }, }; fn deinit( + core: *mach.Core.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod, ) !void { sprite_pipeline.schedule(.deinit); + core.schedule(.deinit); } fn init( + core: *mach.Core.Mod, sprite_pipeline: *gfx.SpritePipeline.Mod, game: *Mod, ) !void { + core.schedule(.init); sprite_pipeline.schedule(.init); game.schedule(.after_init); } @@ -95,9 +100,11 @@ fn afterInit( .allocator = allocator, .pipeline = pipeline, }); + + core.schedule(.start); } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, sprite: *gfx.Sprite.Mod, @@ -241,6 +248,7 @@ fn endFrame(game: *Mod, core: *mach.Core.Mod) !void { "sprite [ FPS: {d} ] [ Sprites: {d} ]", .{ game.state().frame_count, game.state().sprites }, ); + core.schedule(.update); game.state().fps_timer.reset(); game.state().frame_count = 0; } diff --git a/examples/sprite/main.zig b/examples/sprite/main.zig index 177875b3..7732839f 100644 --- a/examples/sprite/main.zig +++ b/examples/sprite/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application. diff --git a/examples/text/App.zig b/examples/text/App.zig index 80ba183f..37a5dbb6 100644 --- a/examples/text/App.zig +++ b/examples/text/App.zig @@ -1,4 +1,3 @@ -// TODO(important): review all code in this file in-depth const std = @import("std"); const zigimg = @import("zigimg"); const assets = @import("assets"); @@ -38,7 +37,7 @@ pub const systems = .{ .init = .{ .handler = init }, .deinit = .{ .handler = deinit }, .after_init = .{ .handler = afterInit }, - .update = .{ .handler = update }, + .tick = .{ .handler = tick }, .end_frame = .{ .handler = endFrame }, }; @@ -52,15 +51,21 @@ const text1: []const []const u8 = &.{ const text2: []const []const u8 = &.{"$!?"}; -fn deinit(text_pipeline: *gfx.TextPipeline.Mod) !void { +fn deinit( + core: *mach.Core.Mod, + text_pipeline: *gfx.TextPipeline.Mod, +) !void { text_pipeline.schedule(.deinit); + core.schedule(.deinit); } fn init( + core: *mach.Core.Mod, text: *gfx.Text.Mod, text_pipeline: *gfx.TextPipeline.Mod, game: *Mod, ) !void { + core.schedule(.init); text.schedule(.init); text_pipeline.schedule(.init); game.schedule(.after_init); @@ -68,6 +73,7 @@ fn init( fn afterInit( entities: *mach.Entities.Mod, + core: *mach.Core.Mod, text: *gfx.Text.Mod, text_pipeline: *gfx.TextPipeline.Mod, text_style: *gfx.TextStyle.Mod, @@ -105,9 +111,11 @@ fn afterInit( .style1 = style1, .pipeline = pipeline, }); + + core.schedule(.start); } -fn update( +fn tick( entities: *mach.Entities.Mod, core: *mach.Core.Mod, text: *gfx.Text.Mod, @@ -268,6 +276,7 @@ fn endFrame( "text [ FPS: {d} ] [ Texts: {d} ] [ Glyphs: {d} ]", .{ game.state().frame_count, num_texts, num_glyphs }, ); + core.schedule(.update); game.state().fps_timer.reset(); game.state().frame_count = 0; } diff --git a/examples/text/main.zig b/examples/text/main.zig index b76e5b52..6f7407d4 100644 --- a/examples/text/main.zig +++ b/examples/text/main.zig @@ -1,4 +1,3 @@ -const std = @import("std"); const mach = @import("mach"); // The global list of Mach modules registered for use in our application.