This bindings are the rawest of the raw for now (i.e. they resemble WebGL functions almost 1to1) since most of the code was generated by handful of scripts that I wrote to speedup the process. This also means that there probably is quite a lot of silliness in this code so take it with a grain of salt.
Having to pass Context
all the time is quite inconvenient and I'm
planing to write something slightly nicer, based on effects
but for
now it is what it is.
Assuming that you already have Idris, installation process is straightforward. (If not go here)
idris --build webgl.ipkg
idris --install webgl.ipkg
Smallest possible example just to get you started.
module Main
import Graphics.WebGL
main : IO ()
main = do
canvas <- getElemById "main"
c <- getContext canvas
clearColor c 1 0 0 1
clear c [ColorBuffer]
To build it you have to specify JavaScript backend and this package:
idris --codegen javascript Main.idr -o WebGLTest.js -p webgl
Now if you create a html page with this script attached and a canvas named "main" you should see it painted in beautiful red. How lovely.
For other examples check the examples folder.
For now for documentation you should use this reference card as the modules should correspond to segments in there or consult the specs.
- Go over all of the generated code.
- Add the documentation.
- Tests? Tests would be nice...
- Write higher-level version based on effects.
- More examples?