
OCaml bindings for raylib (v3.0.0), a simple and easy-to-use library to enjoy videogames programming.
The bindings are pretty faithful to the original C code, the biggest difference is the conversion of all function names from CamelCase to snake_case. Wherever possible, integer arguments are changed to their own variant types, eg. int key to Key.t.
Bindings exist for (nearly) all functions and types, but only a subset are tested thus far (see examples folder). Rough edges are to be expected.
let setup () =
Raylib.init_window 800 450 "raylib [core] example - basic window";
Raylib.set_target_fps 60
let rec loop () =
match Raylib.window_should_close () with
| true -> Raylib.close_window ()
| false ->
let open Raylib in
begin_drawing ();
clear_background Color.raywhite;
draw_text "Congrats! You created your first window!" 190 200 20
Color.lightgray;
end_drawing ();
loop ()
let () = setup () |> loopFurther examples can be found in the examples folder.
Currently, the automated build works only on Linux. A Windows build (mingw64 pins) is possible, but requires a bit of manual fiddling. The library is built with cmake from source, therefore cmake and raylib's dependencies must be present, for details see here.
From the OCaml side, the library depends on ctypes and ppx_cstubs and uses dune as its build system:
dune buildThis also builds the examples.