package gles3
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=97d5f94438632d3811aad5ced0d60f92
sha512=dfaf38e17ffb8ec8e071e361579202f49a600291507a30efb772a224b6c66369aa29ea17e5cd5ebaab0b9bdb9026754043622e31fbc649c0e92bbd5d6ba4b417
Description
This project aims at providing a portable way to write OpenGL (more preciselyOpenGL ES) application in OCaml. It comes in three parts:* Low level bindings allowing direct calls to OpenGL ES functions. Thesebindings try to remain reasonably type-safe using polymorphic variantsto encode enumeration types. The low level bindings also provide somesanity checks for the size of bigarrays which allow to capture quite alot of errors with clear messages.* High level bindings providing auxiliary functions like matrix inversionto ease the development. For instance, to use shaders with the highlevel bindings, you may use compile_shader with the sources code, toget a value of type unit program. Then, you can set the variables ofthe shaders (uniform or attributes), either as constant or function andget an OCaml function to finally run the shaders.* A wrapper to open a window, start the main loop and interact. Currentlyonly EGL under X11 is supported, but we would like to support differentplatforms in the future (Windows, Android, iOS, Wayland, ...) withoutchanging the interface.
README
OCaml OpenGL ES 3.0 bindings

Introduction
This project aims at providing a portable way to write OpenGL (more precisely OpenGL ES) application in OCaml. It comes in three parts:
- Low level bindings allowing direct calls to OpenGL ES functions. These bindings try to remain reasonably type-safe using polymorphic variants to encode enumeration types. The low level bindings also provide some sanity checks for the size of bigarrays which allow to capture quite a lot of errors with clear messages.
- High level bindings providing auxiliary functions like matrix inversion to ease the development. For instance, to use shaders with the high level bindings, you may use
compile_shaderwith the sources code, to get a value of typeunit 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:
- X11+EGL
- Wayland+EGL
We would like to support different platforms in the future (Windows, Android, iOS, ...) without changing the interface.
Authors
- Alexandre Miquel (initial low level bindings for GLES 2)
- Christophe Raffalli (partial port to GLES 3.0, high-level bindings and examples)
- Rodolphe Lepigre (maze example and port to the dune build system)
Installation
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.gitDocumentation
The 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, usingdomainto 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.
Contributing
Contributions are very welcome!
Things to do:
- Test a lot.
- Write more documentation.
- Complete the low-level bindings (see
PRIMITIVES). - Improve the high-level bindings guided by more examples.
- Provide support for more platforms.
- Find a way to support multiple version of GLES (at least 2.0, 3.0, 3.1, 3,2) with only one OCaml library, and possibly in a transparent way when using the high-level bindings (i.e., the high level bindings should test the version and make the best choice).
- Collect regexp for error message in GLSL for most GLES vendors to give good error messages in all cases (only nouveau/mesa is currently supported). It seems that OpenGL ES does not standardize even error message positions.
Dependencies (3)
-
ocaml
>= "5.2.0" -
gles3-stubs
= version -
dune
>= "3.23"
Dev Dependencies (1)
-
odoc
with-doc
Used by (4)
Conflicts
None