raylib #
This is an experimental raylib bindings generated from the original rylib-ocaml project. See Credits section below.
OCaml bindings for raylib 6.0 and
raygui, with the C libraries vendored in
the repository and built by Dune. Exact vendored revisions are recorded in
VENDOR.md.
The public API follows the previous raylib-ocaml convention: C function names
are exposed in snake_case and common raylib structs are available as ctypes
values.
Status #
This is the initial raylib 6 project split. The binding surface is seeded from the raylib 5 OCaml bindings and updated for the raylib 6/raygui APIs needed for the project to build.
Build #
Install OCaml dependencies with opam, then build:
opam install . --deps-only --with-test
dune build
On Linux, this project builds the vendored raylib GLFW backend with Wayland
enabled, X11 disabled, and hardware OpenGL rendering enabled. Install OpenGL,
Wayland, Wayland protocols, and xkbcommon development packages before building.
The opam metadata declares conf-libgl, conf-libwayland,
conf-wayland-protocols, and conf-xkbcommon for those system dependencies.
Example #
let setup () =
Raylib.init_window 800 450 "raylib 6 from OCaml";
Raylib.set_target_fps 60
let rec loop () =
if Raylib.window_should_close () then Raylib.close_window ()
else begin
Raylib.begin_drawing ();
Raylib.clear_background Raylib.Color.raywhite;
Raylib.draw_text "Hello from OCaml" 190 200 20 Raylib.Color.lightgray;
Raylib.end_drawing ();
loop ()
end
let () =
setup ();
loop ()
Credits #
This library is a new project, but it is explicitly based on the design,
generated ctypes binding approach, examples, and practical experience of
raylib-ocaml by Tobias Mock.
The OCaml binding code keeps the same MIT license as the original project, and
the original copyright attribution is preserved in LICENSE and NOTICE.md.