Added timers
This commit is contained in:
@ -63,3 +63,40 @@ test "set and get target FPS" {
|
||||
try std.testing.expectEqual(fps, getTargetFPS());
|
||||
}
|
||||
}
|
||||
|
||||
pub const Timer = struct {
|
||||
ctimer: *minifb_c.mfb_timer,
|
||||
|
||||
pub fn init() !Timer {
|
||||
const ctimer: ?*minifb_c.mfb_timer = minifb_c.mfb_timer_create();
|
||||
if (ctimer) |value| {
|
||||
return Timer {.ctimer=value};
|
||||
} else {
|
||||
return error.ItBroke;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deinit(self: Timer) void {
|
||||
minifb_c.mfb_timer_destroy(self.ctimer);
|
||||
}
|
||||
|
||||
pub fn reset(self: Timer) void {
|
||||
minifb_c.mfb_timer_reset(self.ctimer);
|
||||
}
|
||||
|
||||
pub fn now(self: Timer) f64 {
|
||||
return minifb_c.mfb_timer_now(self.ctimer);
|
||||
}
|
||||
|
||||
pub fn delta(self: Timer) f64 {
|
||||
return minifb_c.mfb_timer_delta(self.ctimer);
|
||||
}
|
||||
|
||||
pub fn getFrequency() f64 {
|
||||
return minifb_c.mfb_timer_get_frequency();
|
||||
}
|
||||
|
||||
pub fn getResolution() f64 {
|
||||
return minifb_c.mfb_timer_get_resolution();
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user