fps limit

This commit is contained in:
cqc
2024-05-10 12:43:37 -05:00
parent a2c73ee1ad
commit 366364c9b2

View File

@ -125,7 +125,7 @@ let () =
in
F.pr "oplevel.ml: entering drawing loop@.";
let period_min = 1.0 /. 30. in
let t = GLFW.getTime () |> ref in
while (not GLFW.(windowShouldClose ~window)) && !continue do
Lwt_main.run
@ -166,6 +166,8 @@ let () =
Gc.major_slice 0 |> ignore;
GLFW.swapBuffers ~window;
GLFW.pollEvents ();
Unix.sleepf
Float.(max 0. (period_min -. GLFW.getTime () +. !t));
Lwt.return_unit)
())
done;