Cross-platform GLFW / OpenGL ES / WebGL bindings for Reason
Branch: master
Clone or download
Latest commit 81d3077 Feb 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci Dependency: Upgrade to esy@0.4.9 (#74) Jan 3, 2019
bin_js Build: Fix compilation error with latest JSOO (#55) Dec 6, 2018
bin_native
config Fix undefined references when building on Linux (#92) Feb 12, 2019
esy.lock Add sharedContext argument to `glfwCreateWindow` (#82) Jan 22, 2019
examples API: glfwGetNativeWindow (#89) Jan 29, 2019
include Dependency: Switch to esy-glfw dep (#67) Jan 5, 2019
src
test Add sharedContext argument to `glfwCreateWindow` (#82) Jan 22, 2019
.gitignore [WIP] Factor image info out (#20) Oct 10, 2018
.travis.yml
LICENSE Initial commit Sep 1, 2018
README.md API: glfwGetNativeWindow (#89) Jan 29, 2019
azure-pipelines.yml Dependency: Upgrade to esy@0.4.9 (#74) Jan 3, 2019
dune Add compilation result to `glCompileShader` (#9) Sep 26, 2018
dune-project [WIP] Dune support (#1) Sep 15, 2018
esy.lock.json [WIP] Factor image info out (#20) Oct 10, 2018
package.json 3.2.1017 Feb 19, 2019
reglfw.opam Update library name Sep 24, 2018
test-fb.sh Add compilation result to `glCompileShader` (#9) Sep 26, 2018
travis-test.sh Get automation running on Travis (#16) Oct 8, 2018

README.md

Build Status Build Status npm version

reason-glfw

Cross-platform Reason / OCaml bindings for GLFW - supports Native (OpenGL) and Javascript (WebGL))

Building

esy is used for building, so if you don't have esy, install it:

npm install -g esy@0.4.9
  • esy install
  • esy build

NOTE: If you've never built with esy before, the first compile could take some time - it builds the ocaml compiler as well as cmake. Incremental builds, though, are extremely fast!

Running

A very simple example project is provided - you can test it out here:

NATIVE:

  • cd _build/install/default/bin
  • ./test_glfw (./test_glfw.exe on Windows)

WEB:

  • Start an http-server at _build/install/default/bin. (I use npm install -g http-server).
  • Navigate to index.html

License

This project is licensed under the MIT License - see LICENSE for more details.

Design

For the most part, we strive to have API compatibility for GLFW and OpenGL. This library supports compilation to both native and JSOO targets. In the JSOO case, we emulate the GLFW APIs.

We do have some exceptions:

glfwGetNativeWindow

We wrap the native window access functions in a function glfwGetNativeWindow. This returns a NativeWindow.t, where the underlying value is platform specific:

  • Windows - HWND for the current window.
  • OSX - void * pointer to the NSWindow.
  • Linux - void * pointer to the X11 Window.
  • JS - HTMLCanvasElement representing the window.

Acknowledgements

  • The test texture is provided by LearnOpenGL - an excellent resource for OpenGL!
  • This is built on several great libraries, like GLFW, glad, stb_image
  • The test image is from @Arahnoid's UVChecker-map repo.