Slightly better time management

This commit is contained in:
nothke 2024-07-04 16:02:52 +02:00
parent fc91b57f33
commit 2524dbf206
1 changed files with 9 additions and 2 deletions

View File

@ -108,16 +108,23 @@ export fn init() void {
}; };
std.log.info("Backend: {}\n", .{sg.queryBackend()}); std.log.info("Backend: {}\n", .{sg.queryBackend()});
sokol.app.showMouse(false);
} }
fn timef() f32 { fn timef() f32 {
return @floatCast(sokol.time.sec(sokol.time.now())); return @floatCast(sokol.time.sec(sokol.time.now()));
} }
var time: f32 = 0;
export fn frame() void { export fn frame() void {
const dt: f32 = @floatCast(sokol.app.frameDuration());
time += dt;
const col = &pass_action.colors[0].clear_value; const col = &pass_action.colors[0].clear_value;
col.g = @abs(@sin(timef())); col.g = @abs(@sin(time));
col.r = @abs(@cos(timef())); col.r = @abs(@cos(time));
state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf(); state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();