From 2524dbf2061fc1e7417f63f5b6f55da95e0d83a8 Mon Sep 17 00:00:00 2001 From: nothke Date: Thu, 4 Jul 2024 16:02:52 +0200 Subject: [PATCH] Slightly better time management --- src/main.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 09cec01..9c3f8e8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -108,16 +108,23 @@ export fn init() void { }; std.log.info("Backend: {}\n", .{sg.queryBackend()}); + + sokol.app.showMouse(false); } fn timef() f32 { return @floatCast(sokol.time.sec(sokol.time.now())); } +var time: f32 = 0; + export fn frame() void { + const dt: f32 = @floatCast(sokol.app.frameDuration()); + time += dt; + const col = &pass_action.colors[0].clear_value; - col.g = @abs(@sin(timef())); - col.r = @abs(@cos(timef())); + col.g = @abs(@sin(time)); + col.r = @abs(@cos(time)); state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();