Page
Library
Module
Module type
Parameter
Class
Class type
Source

This project aims at providing a portable way to write OpenGL (more precisely OpenGL ES) application in OCaml. It comes in three parts:
compile_shader with the sources code, to get a value of type unit program. Then, you can set the variables of the shaders (uniform or attributes), either as constant or function and get an OCaml function to finally run the shaders.A wrapper to open a window, start the main loop and interact. Currently the following framework are supported:
We would like to support different platforms in the future (Windows, Android, iOS, ...) without changing the interface.
To install from source, clone the repository and run make && make install. Alternatively, you can pin the repository using the following commands (only one of latest two is useful):
opam pin add gles3-stubs.dev https://github.com/craff/gles3.git
opam pin add gles3.dev https://github.com/craff/gles3.git
opam pin add gles3-x11.dev https://github.com/craff/gles3.git
opam pin add gles3-wayland.dev https://github.com/craff/gles3.gitThe OCaml documentation can be extracted to a webpage using make doc. The generate page is the placed at _build/default/_doc/_html/index.html).
The repository also contains multiple examples:
examples/flying_cube: a rotating cube.examples/curves: a wire-frame cubeexamples/exploding_cube: the names says it allexamples/cubeTexture: a rotating cube with a texture (including a text).examples/cubesAndShapes: rotating cubes and 8 implicit surfaces with simple shadow mapping.examples/spheres: many bouncing spheres, using domain to run multicore.examples/maze: a maze generator with a simple exploration camera.examples/click: illustrates how to use a shader to click on object and get the ID of the object and the position of the clicked point in 3D.examples/window: flying_cube in two distinct windows.To run the examples: to run an example, move to its directory and run one of the two following commands
BUILD_WAYLAND_EXAMPLES=true dune exec -- <name>_wayland.exewhere name is the name of the file defining the example without extension. example: flying_cube_x11.exe for the first example.
Contributions are very welcome!
Things to do:
PRIMITIVES).