{Core,examples}: set window title via component

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-21 22:48:30 -07:00 committed by Stephen Gutekanst
parent 79dccb4d73
commit 68677b3448
5 changed files with 104 additions and 19 deletions

View file

@ -57,9 +57,6 @@ fn afterInit(
glyphs: *Glyphs.Mod,
game: *Mod,
) !void {
// The Mach .core is where we set window options, etc.
mach.core.setTitle("gfx.Sprite example");
// Create a sprite rendering pipeline
const texture = glyphs.state().texture;
const pipeline = try sprite_pipeline.newEntity();
@ -231,7 +228,7 @@ fn tick(
game.state().time += delta_time;
}
fn endFrame(game: *Mod) !void {
fn endFrame(game: *Mod, core: *mach.Core.Mod) !void {
// Finish render pass
game.state().frame_render_pass.end();
const label = @tagName(name) ++ ".endFrame";
@ -245,7 +242,13 @@ fn endFrame(game: *Mod) !void {
// Every second, update the window title with the FPS
if (game.state().fps_timer.read() >= 1.0) {
try mach.core.printTitle("gfx.Sprite example [ FPS: {d} ] [ Sprites: {d} ]", .{ game.state().frame_count, game.state().sprites });
try mach.Core.printTitle(
core,
core.state().main_window,
"glyphs [ FPS: {d} ] [ Sprites: {d} ]",
.{ game.state().frame_count, game.state().sprites },
);
core.send(.update, .{});
game.state().fps_timer.reset();
game.state().frame_count = 0;
}