mach: fundamental changes

- Core doesn't depend to `App` anymore
 - `setOptions` has replaced with some new functions (`setTitle`,
   `setSize`, etc)
   - and more
This commit is contained in:
Ali Chraghi 2023-01-10 15:53:29 +04:00 committed by Stephen Gutekanst
parent 91a53807ab
commit 1d7cd4be80
26 changed files with 2306 additions and 1999 deletions

View file

@ -0,0 +1,25 @@
const std = @import("std");
const js = @import("js.zig");
pub const Timer = @This();
initial: f64 = undefined,
pub fn start() !Timer {
return Timer{ .initial = js.machPerfNow() };
}
pub fn read(timer: *Timer) u64 {
return (js.machPerfNow() - timer.initial) * std.time.ns_per_ms;
}
pub fn reset(timer: *Timer) void {
timer.initial = js.machPerfNow();
}
pub fn lap(timer: *Timer) u64 {
const now = js.machPerfNow();
const initial = timer.initial;
timer.initial = now;
return @floatToInt(u64, now - initial) * std.time.ns_per_ms;
}