Monthly Archives: September 2006

Installing cl-opengl on Mac OS X

Ok I am back with one more rant on Lisp.

Because of an idea I have, that is not yet ripe for decision, I was trying to get a graphics library that is portable and has a Common Lisp binding. Finally I got stuck on opengl and cl-opengl binding. I had a hard time getting it to run on Mac OS X so I tried it on Linux first where it worked out of the box. It is pretty nice even if making a mistake sometimes kills your lisp.

To install cl-opengl you need a Common Lisp implementation (I use sbcl), cffi (I used cffi 0.9.1), an opengl library (I used the one shipping with Mac OS X) and GLUT (I used OpenGLUT but more on that later).

First I tried to get cl-opengl running with the native Mac OS X GLUT implementation but it did not work. I found information on the cl-opengl list that you need FreeGLUT. The problem with FreeGLUT is that it does not compile on Mac because of some joistick problems.

So… get the source tarball of OpenGLUT.

Untar it and run “CPPFLAGS=”-I/usr/X11R6/include” ./configure”. You need the CPPFLAGS variable because otherwise the build system will not find the right opengl headers.

Now run make and make install. In my case I added the option –prefix=/opt/mine to configure to not taint the running system with self compiled stuff.

Finally you should end up with OpenGLUT libraries.

Now download cl-opengl (probably using darcs “darcs get http://www.common-lisp.net/project/cl-opengl/darcs/cl-opengl/”)

Link the .asd files to your sbcl systems directory:
# ln -s ~/cl-opengl/*.asd ~/.sbcl/systems

The problem with OpenGLUT is that it uses X11 to create windows. So you have to start the Mac OS X X11 server and start sbcl in the xterm within X11.
After starting sbcl you can run at the repl the following:
* (asdf:operate ‘asdf:load-op ‘cl-glut-examples)

That should compile and load the cl-opengl cl-glut and cl-glu bindings and also cl-glut-examples.

Now you should be able to test it running:
* (cl-glut-examples:gears)

on the sbcl repl.

Conclusion:

cl-opengl binding is really nice. It still needs work so that it catches all errors that may occur. Doing something unpredicted with opengl may cause your lisp process to crash.
It also requires at least FreeGLUT that is not willing to compile on Mac OS X but that is understandable because GLUT itself misses some features that are required to create really dynamic applications what is what you want. OpenGLUT does compile on Mac OS X but seems to be pretty old (2005 last release) and just like FreeGLUT requires X11. That is really nasty. I do not want X11 🙁

It is usable it is pretty nice but there still is a lot to do! I will for sure dive more into that stuff and try to fix at least some of the problems I found.

But nonetheless thanks OpenGLUT and cl-opengl guys for your fine work! Now I can finally create some nice graphical stuff! Woot!

One more thing… the cl-glut-examples:gears demo gives the following frame rates on my MacBook Pro:
23857 frames in 5.0 seconds = 4771.400 FPS
24407 frames in 5.0 seconds = 4881.400 FPS
24316 frames in 5.0 seconds = 4863.200 FPS
24293 frames in 5.0 seconds = 4858.600 FPS

I think it is amazing! Tell me what framerates you get! 😉

Back from Scotland

You probably know it already but I am back from Schotland. I spent 10 days on the Ile of Arran with some friends. We Made a 100km tour around it. I shot about 460 images and hope that there will be something useful among them. But you will have to judge for yourself.

We arrived back in germany last friday and I was fighting with my emails and rss feeds. Now I am catching up with other things. I hope that I will have enough time to work through the Scotland images in the next days and put them online in my gallery.

My photoblog seems to be working pretty well. It was running on auto pilot the last two weeks and I think that it is a pretty nice thing. I will now put more images online and they will get visible over time. That makes the blog regular and I do not need to spend so much time on it. But I will now start answering your comments in the photoblog. If you provide your email address then you will also get an email. (the email address will not get posted so do not fear).