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