Re: lablGL and GLX extentions?

Florent Monnier <[email protected]> Wed, 7 Jan 2009 15:00:20 +0100
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
> > Also I have made an attempt to make a simili-functional opengl interface:
> > http://www.linux-nantes.org/~fmonnier/OCaml/GL/doc/FunGL.html
>
> Ow, the colours on that page make it a little hard to read.

hard to read for you. for me it's easier to read.
my eyes just burn with white backgrounds.
but you can change very easily the style of every ocamldoc doc:
just change the .css style file, they are all compatible so you can take 
the .css file from another ocaml package and put it in the docs of ocaml-xlib 
or glMLite.

alternatively you can remove the parameter "-css-style _style.css" in the 
Makefiles of these packages.

> Is this an alternative to lablGL?

There are 3 OCaml-OpenGL bindings:
http://cocan.org/comparisons/gui#Bindings_to_the_OpenGL_3D_library

- LablGL
- GLCaml
- glMLite

LablGL is the older one, so people got used to it.
I think you have already browsed the ocamldoc of LablGL,
here are the ones for the two others :
- http://www.linux-nantes.org/~fmonnier/OCaml/GL/doc/
- http://glcaml.sourceforge.net/doc/Glcaml.html


> > and you can get a pixmap from a window.
>
> I was a bit stuck on  how to do the second part.

I imagine the process could be:
(1) create the window
(2) create the pixmap
(3) copy from the window to the pixmap with xCopyArea:
http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/doc/Xlib.html#VALxCopyArea
http://tronche.com/gui/x/xlib/graphics/XCopyArea.html

but with the extention (see below) maybe the process is optimised

> What I'm basically try to do is place 2D application windows in a 3D
> space, much like SUN's Project Looking Glass:
>
>     http://www.sun.com/images/k3/k3_lglass_gallery3.gif

this is exactly to achieve this kind of things that I have written these 
bindings ;-)
(well also to write screensavers in ocaml, a more simple thing to start with;)

> and then handle mouse and keyboard events and pass them on down to
> the 2D windows as required.

yes the hard part is doing the math (not the C functions wrapped)
but perhaps there is some freedom code arround from where to steal the formula


> I  tried to compile that with  the  shell script provied  but got:
>
>     Cannot find file GL.cma.

install glMLite, or even without installing it, you can just open its tarball 
in /tmp run the make there, then from the ocaml-xlib dir run:

cd /tmp
wget \
http://www.linux-nantes.org/%7Efmonnier/OCaml/GL/download/glMLite-0.03.27.tgz
tar xzf glMLite-0.03.27.tgz
cd glMLite-0.03.27
make
cd  your/path/until/OCaml-Xlib/
make clean ; make Xlib.cma GLX.cma
ocaml \
  -I /tmp/glMLite*/SRC/  GL.cma Glu.cma \
  -I . Xlib.cma GLX.cma \
  pixmap_to_gl.ml


> I am under the impression that I need glXBindTexImageEXT,
> glXReleaseTexImageEXT and maybe some others.

Ha I see, these functions don't appear in the base manual (I only read the 
manual until now), it is an extension :
http://people.freedesktop.org/~davidr/GLX_EXT_texture_from_pixmap.txt

I guess it provides an optimisation or usefull additional options, because the 
script "pixmap_to_gl.ml" already works, but doing real-time this way would 
perhaps be too slow.

I see the functions of this extention are in my header, I will wrap it in the 
next days.

Hey is your project an open-source project ?
If it is the case you will guess that I could be interested :-)

-- 
Regards
Florent