Neko OpenGL binding
Xinf includes a library for using OpenGL from neko. Currently, not all OpenGL functions are wrapped, but a substantial (and useful) amount is in fact there.
In detail, NekoOpenGL provides bindings for GL, GLU and GLUT (generated with NekoBind). You should bring some experience with OpenGL (see the RedBook), as i will never document all the functions.
Yet, for a start, here are some basic facts you'll need to know if you use NekoOpenGL:
Basic Function Binding
Most OpenGL functions are wrapped into static functions of the global classes GL, GLU and GLUT:
- static values (#defines in gl.h) are represented as static variables in the corresponding class, stripping the "GL_" prefix: "GL_DEPTH" becomes "opengl.GL.DEPTH".
- the "gl" (or glu/glut) prefix is stripped, and the first character of the remaining function name is decapitalized. I.e., glViewport() becomes GL.viewport().
- thanks to NekoBind, you can pass in neko floats or ints wherever a numeric value is required.
- many functions that support multiple variants (double/float/int) are stripped down to the double variant, as neko floats are always C doubles. The variant suffix is stripped. I.e., "glVertex3d" becomes "GL.vertex3".
- functions requiring C data pointers take values allocated with NekoCPtr. They should be memory-safe (which is not to say you can't still mess up).
Extra functionality
I've included some functionality which i need for XinfInity?, but which might be useful to you, too:
- the Helper class includes wrappers around the glGet[Bool/Int/Float/Double] functions, with variants for getting simple single values as well as multiple values with arrays. You'll need to look out with the "interest" parameters in the getXXXs variants- it should correspond to the number of parameters actually delivered by OpenGL, determined by the parameter name.
- the Helper class also includes two (not really efficient) functions for evaluating quadratic and cubic beziers to a neko callback function.
- a simple GLU Tesselator with some support functions.
About GLUT
After some experimentation with native APIs, and using libSDL before, I've now (for the time being) resorted to using GLUT for platform support (ie., opening windows and handling UI-events). As GLUT is relatively limited (eg., no shared contexts for multiple windows), I'm likely to replace this with platform-native functionality (GLX on Linux, wGL on Windows, AGL on Mac) some time in the future. For now, GLUT does it just fine, though, and I will likely continue to support it, in case people use it directly for their applications. It might move to its own HaxeLib then, though.
Installation and Test
You can simply install NekoOpenGL with HaxeLib, it supports all NekoPlatforms.
haxelib install opengl
Using haxelib run will run the integrated test:
$ haxelib run opengl
It should open a window showing a nice rotating white-wire/red-solid cube, like this:
If the test fails, please let me know on the [MailingList].
no other docs, sorry
That's it for now. If you have questions, please first look at the Sample, then ask specific questions on the MailingList. I will continue documenting here as i answer those questions.
