package bogue

  1. Overview
  2. Docs

Time in msec.

Dependency graph
type t = int
val now : unit -> t

Time elapsed from the initialization of SDL (roughly, since the start of your program).

val adaptive_fps : ?vsync:bool -> int -> (unit -> unit) * (unit -> unit)

Create helper functions to help controlling the frame rate of the graphics loop. This is only useful if you have your own graphics loop, and do not use Main.run.

adaptive_fps 60 returns two functions start,fps. The statement start () will start the timing. At each iteration of your loop, you should call fps (), which will try to sleep long enough to achieve the desired 60FPS rate. It works on average: if some frames take longer, it will shorten the next frame to keep up. However, it tries to be nice to the CPU: even if one is really too slow, it will guarantee a 5ms sleep to the CPU and not try to keep up.

vsync is false by default, when true it sets GL swap interval to 1 to wait for next vsync, and if it can't keep up with that during animation it will set swap interval to -1 if supported by platform to use adaptive vsync. (Which should avoid forcing the animation rate to an integer ratio of monitor refresh rate.)

See also Main.get_monitor_refresh_rate

OCaml

Innovation. Community. Security.