Get and set frame rate
This commit is contained in:
@ -12,7 +12,7 @@ pub fn build(b: *std.build.Builder) void {
|
||||
var main_tests = b.addTest("src/minifb.zig");
|
||||
main_tests.setBuildMode(mode);
|
||||
main_tests.setTarget(target);
|
||||
link(b, main_test);
|
||||
link(b, main_tests);
|
||||
|
||||
const test_step = b.step("test", "Run library tests");
|
||||
test_step.dependOn(&main_tests.step);
|
||||
|
@ -44,6 +44,22 @@ pub const Window = struct{
|
||||
else => return UpdateError.InternalError,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
pub fn getTargetFPS() u32 {
|
||||
return minifb_c.mfb_get_target_fps();
|
||||
}
|
||||
|
||||
pub fn setTargetFPS(fps: u32) void {
|
||||
minifb_c.mfb_set_target_fps(fps);
|
||||
}
|
||||
|
||||
// TODO Figure out how to run this once I have Internet access.
|
||||
test "set and get target FPS" {
|
||||
const max = 40;
|
||||
var fps: u32 = 30;
|
||||
while (fps < max) {
|
||||
setTargetFPS(fps);
|
||||
try std.testing.expectEqual(fps, getTargetFPS());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user