Re: lablGL and GLX extentions?

Florent Monnier <[email protected]> Wed, 7 Jan 2009 09:25:38 +0100
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
> Hi all,
Hi you,

> I've done a bit of lablGL coding and found it a far superior way
> of coding OpenGL in comparsison to doing it from C or Python.

On which points? could you develop?

Also I have made an attempt to make a simili-functional opengl interface:
http://www.linux-nantes.org/~fmonnier/OCaml/GL/doc/FunGL.html
I got no feedback yet about this rather experimental thing, and would be 
really interested to get some, to get an idea of the direction to make it 
evoluate.
This module is currently glMLite compatible but it is rather independent from 
it. It would be very easy to make a LablGL compatible version.
If you are interested to test/try it and tell me what you think about it, I 
would be happy to provide you a LablGL-compatible version.

> I now need to be able to embed an X window on a surface in OpenGL
> which I think requires GLX extensions (glxGetConfig, glxChooseVisual
> etc).

It is possible to compose a pixmap into an OpenGL texture, and you can get a 
pixmap from a window. And you can currently do all this from OCaml.

This technique is explained here (for C):
http://www.opengl.org/wiki/index.php/Programming_OpenGL_in_Linux:_Creating_a_texture_from_a_Pixmap

It can be achieved from OCaml in exactly the same way.
I have made an ocaml version of this demo program.
This script is called "pixmap_to_gl.ml" in the Xlib-OCaml bindings here:
http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/

You will see that in fact you do not need GLX to achieve this, but only the 
Xlib module. This script also uses GLX but it's only for the windowing, you 
can switch it to Glut or SDL or something else.

> Does lablGL support these GLX extentions (maybe the names have
> changed)?

LablGL only supports the OpenGL and GLU apis. It does not support windowing at 
all. Windowing is achieved with an additional module that you can choose, 
because there are no dependencies between the OpenGL modules and the 
windowing modules.
You can choose LaglGlut, SDL, Togl (Tk), GLX. You could even use the Glut 
module from glMLite with LablGL, which supports the last Glut version which 
is named OpenGlut which provides enhancements and additionnal features.
(but it stays compatible with the old outdated Glut)

So to answer to your question, yes you can use LablGL with GLX:
http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/doc/GLX.html

(there are still a couple of functions from the GLX api that are not wrapped 
yet, if you need those just ask)

>           Anybody working on supporting it?

Google with the key words "ocaml GLX" would had give you this answer in first 
page. But indeed perhaps with less details than my email :-)
The OCaml-Hump also provides the answer with the keyword "GLX"

>                                             Any example code? :-)

There are several examples of use of GLX provided in the tarball:
http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/
All these examples use glMLite, but it's easy to switch from glMLite to 
LablGL, you can use the script named "glMLite_to_LablGL.sed.sh".
You could also use this script to help converting from C to LablGL, while the 
function names of glMLite are kept from C.

Hope this helps
Florent

PS: you are not on the LablGL mailing list but on the LablGTK one!