From 4a000c79956ae1c7445600a371f1b00e72fea4b9 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Mon, 22 Apr 2024 05:37:13 -0700 Subject: [PATCH] {Core,examples}: add TODO markers for core APIs that require module exposure Signed-off-by: Stephen Gutekanst --- examples/core-custom-entrypoint/Game.zig | 3 +++ examples/custom-renderer/Game.zig | 1 + examples/custom-renderer/Renderer.zig | 4 +--- examples/glyphs/Game.zig | 3 +++ examples/piano/Piano.zig | 3 +++ examples/sprite/Game.zig | 2 ++ examples/text/Game.zig | 2 ++ src/gfx/SpritePipeline.zig | 1 + src/gfx/TextPipeline.zig | 1 + 9 files changed, 17 insertions(+), 3 deletions(-) diff --git a/examples/core-custom-entrypoint/Game.zig b/examples/core-custom-entrypoint/Game.zig index 6160e7e2..a99a5dfe 100644 --- a/examples/core-custom-entrypoint/Game.zig +++ b/examples/core-custom-entrypoint/Game.zig @@ -61,6 +61,7 @@ pub fn deinit(game: *Mod) void { // 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. + // TODO(Core) var iter = mach.core.pollEvents(); while (iter.next()) |event| { switch (event) { @@ -70,6 +71,7 @@ fn tick(core: *mach.Core.Mod, game: *Mod) !void { } // Grab the back buffer of the swapchain + // TODO(Core) const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?; defer back_buffer_view.release(); @@ -119,6 +121,7 @@ fn updateWindowTitle(core: *mach.Core.Mod) !void { core.state().main_window, "core-custom-entrypoint [ {d}fps ] [ Input {d}hz ]", .{ + // TODO(Core) mach.core.frameRate(), mach.core.inputRate(), }, diff --git a/examples/custom-renderer/Game.zig b/examples/custom-renderer/Game.zig index b6f72f05..c559eebd 100644 --- a/examples/custom-renderer/Game.zig +++ b/examples/custom-renderer/Game.zig @@ -77,6 +77,7 @@ fn tick( game: *Mod, ) !void { // TODO(important): event polling should occur in mach.Core module and get fired as ECS event. + // TODO(Core) var iter = mach.core.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 eb1b2680..30d0a40f 100644 --- a/examples/custom-renderer/Renderer.zig +++ b/examples/custom-renderer/Renderer.zig @@ -122,10 +122,8 @@ fn tick( core: *mach.Core.Mod, renderer: *Mod, ) !void { - const device = core.state().device; - _ = device; // autofix - // Grab the back buffer of the swapchain + // TODO(Core) const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?; defer back_buffer_view.release(); diff --git a/examples/glyphs/Game.zig b/examples/glyphs/Game.zig index a77cdfe4..373a3a31 100644 --- a/examples/glyphs/Game.zig +++ b/examples/glyphs/Game.zig @@ -96,6 +96,7 @@ fn tick( game: *Mod, ) !void { // TODO(important): event polling should occur in mach.Core module and get fired as ECS events. + // TODO(Core) var iter = mach.core.pollEvents(); var direction = game.state().direction; var spawning = game.state().spawning; @@ -163,6 +164,7 @@ fn tick( for (ids, transforms) |id, *old_transform| { var location = old_transform.translation(); // TODO: formatting + // TODO(Core) if (location.x() < -@as(f32, @floatFromInt(mach.core.size().width)) / 1.5 or location.x() > @as(f32, @floatFromInt(mach.core.size().width)) / 1.5 or location.y() < -@as(f32, @floatFromInt(mach.core.size().height)) / 1.5 or location.y() > @as(f32, @floatFromInt(mach.core.size().height)) / 1.5) { try core.entities.remove(id); game.state().sprites -= 1; @@ -200,6 +202,7 @@ fn tick( game.state().frame_encoder = core.state().device.createCommandEncoder(&.{ .label = label }); // Grab the back buffer of the swapchain + // TODO(Core) const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?; defer back_buffer_view.release(); diff --git a/examples/piano/Piano.zig b/examples/piano/Piano.zig index 112bf6f3..4e706547 100644 --- a/examples/piano/Piano.zig +++ b/examples/piano/Piano.zig @@ -78,6 +78,7 @@ fn tick( audio: *mach.Audio.Mod, piano: *Mod, ) !void { + // TODO(Core) var iter = mach.core.pollEvents(); while (iter.next()) |event| { switch (event) { @@ -111,6 +112,7 @@ fn tick( } // Grab the back buffer of the swapchain + // TODO(Core) const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?; defer back_buffer_view.release(); @@ -174,6 +176,7 @@ fn fillTone(audio: *mach.Audio.Mod, frequency: f32) ![]const f32 { return samples; } +// TODO(Core) fn keyToFrequency(key: mach.core.Key) f32 { // The frequencies here just come from a piano frequencies chart. You can google for them. return switch (key) { diff --git a/examples/sprite/Game.zig b/examples/sprite/Game.zig index 6b7f0a78..df97ad4d 100644 --- a/examples/sprite/Game.zig +++ b/examples/sprite/Game.zig @@ -90,6 +90,7 @@ fn tick( game: *Mod, ) !void { // TODO(important): event polling should occur in mach.Core module and get fired as ECS events. + // TODO(Core) var iter = mach.core.pollEvents(); var direction = game.state().direction; var spawning = game.state().spawning; @@ -184,6 +185,7 @@ fn tick( game.state().frame_encoder = core.state().device.createCommandEncoder(&.{ .label = label }); // Grab the back buffer of the swapchain + // TODO(Core) const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?; defer back_buffer_view.release(); diff --git a/examples/text/Game.zig b/examples/text/Game.zig index 281cce4a..7d4a9b4d 100644 --- a/examples/text/Game.zig +++ b/examples/text/Game.zig @@ -128,6 +128,7 @@ fn tick( game: *Mod, ) !void { // TODO(important): event polling should occur in mach.Core module and get fired as ECS events. + // TODO(Core) var iter = mach.core.pollEvents(); var direction = game.state().direction; var spawning = game.state().spawning; @@ -228,6 +229,7 @@ fn tick( game.state().frame_encoder = core.state().device.createCommandEncoder(&.{ .label = label }); // Grab the back buffer of the swapchain + // TODO(Core) const back_buffer_view = mach.core.swap_chain.getCurrentTextureView().?; defer back_buffer_view.release(); diff --git a/src/gfx/SpritePipeline.zig b/src/gfx/SpritePipeline.zig index 7e6d4be2..c05fe793 100644 --- a/src/gfx/SpritePipeline.zig +++ b/src/gfx/SpritePipeline.zig @@ -341,6 +341,7 @@ fn preRender(sprite_pipeline: *Mod, core: *mach.Core.Mod) void { // Create the projection matrix // TODO(sprite): move this out of the hot codepath const proj = math.Mat4x4.projection2D(.{ + // TODO(Core) .left = -@as(f32, @floatFromInt(mach.core.size().width)) / 2, .right = @as(f32, @floatFromInt(mach.core.size().width)) / 2, .bottom = -@as(f32, @floatFromInt(mach.core.size().height)) / 2, diff --git a/src/gfx/TextPipeline.zig b/src/gfx/TextPipeline.zig index 3d8543a0..4556f0e7 100644 --- a/src/gfx/TextPipeline.zig +++ b/src/gfx/TextPipeline.zig @@ -366,6 +366,7 @@ fn preRender(text_pipeline: *Mod, core: *mach.Core.Mod) void { // Create the projection matrix // TODO(text): move this out of the hot codepath const proj = math.Mat4x4.projection2D(.{ + // TODO(Core) .left = -@as(f32, @floatFromInt(mach.core.size().width)) / 2, .right = @as(f32, @floatFromInt(mach.core.size().width)) / 2, .bottom = -@as(f32, @floatFromInt(mach.core.size().height)) / 2,