Get and set frame rate

This commit is contained in:
2021-11-24 11:15:33 -07:00
parent 149cf2a9b4
commit 3778320a3e
3 changed files with 24 additions and 7 deletions

View File

@ -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);

View File

@ -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());
}
}