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).

Lisp Machines

Some days ago I watched some Lisp Machine Videos. These films show what it was like to use a lisp machine and code on it.

I really have to admit that I was not surprised to see what wonderful ideas the guys had back then. Current OS’s still have a long way to go to incorporate (copy) the functionality you had 20 years ago in LispM Operating systems like Genera. Apple as always is on the front line of incorporating this old stuff. For example Time Machine. The new feature that will be there in Leopard (the next version of Mac OS X). The idea of easily going back in time and looking at your files was there 20 year ago.

Still as I now know Time Machine is still far away from the idea the LispM developers had. There you had a filesystem that had versioning built in. You can tell you do not save files just like that. You save patches to your files. That is somehow comparable to having SVN as your filesystem. Just a bit more sophisticated.

Sure that is not the only thing. There are tons of others. Like objects that are mouse sensitive depending on what you are doing. Accessing the displayed object structures that are behind that what you see. And many more…

I do not want to let myself get carried away too much. The condensed idea I wanted to share with you is the following. Genera is amazing. And if you think that any currently known OS is cool then you know nothing. And if you think that Java and Eclipse are cool then you live in the stone age in the matter of knowledge.

Sit down, learn lisp. It may hurt at first, but the freedom is worth it. Others had to pay their lives for freedom and you only have to learn.

Flashing M16C and R8C under Linux and Mac OS X

Yesterday and the day before Uwe and I were trying to flash an R8C and alternatively an M16C under Linux. We were finally successful using the Flasher from Thomas Fischl. You have to be careful to get the one on his site not the original from Lost In The Ether. The original seems to be somewhat broken.

Still there are some points you should be careful about. First of all the image you want to flash has to be for R8C or M16C respectively. The problem is that the addresses contained in the images have different order (endianes) depending on the chip. The sample srecord image contained in the tarball from Fischl is for _M16C_ and _NOT_ R8C.

Next thing is you should try to use a real hardware serial interface if you get problems with a serial to usb converter. We found out that even if the converter contains a prolific usb to serial chip it does not mean that it will work. We have two cables here and we know that Sitecom works.

We will probably write a patch for the flasher program containing some additional documentation and some checks and timeouts. The checks should validate the addresses one wants to flash are valid for the chip, and the program should timeout if it does not get data back from the chip during flashing. At least that is our TODO.

More information to come. 😉

[Update] Added some links.

Why Nerds are Unpopular

Today I found a very nice article about $TOPIC. You can find it here.

Like most articles by Paul Graham it brings a lot of interesting light to the topic. If you ever considered yourself a nerd, or still are, you should for sure read it. It is based around the social dynamics in american schools but I think you can transfer many of the ideas to other countries and cultures.

Have fun reading.

Watching Grass Grow

If you are also in the same situation as myself and feel all tensed because of an exam … perhaps watching grass grow will calm down your nerves a bit.

Over some corners and edges of the internet I came to this “Watching Grass Grow” website.

(yes I know this post is the most useless till now but I had to share that with you)

Lisp Interpreter in Java Script

Today I found something pretty nice a Lisp interpreter in Java Script.

I came to it through logowiki. I found it pretty amazing that you can run the example programs you have in your wiki. So I asked google about it.

The interpreter lacks some functionality like defun, defmacro and so on but I think it would be a nice base for creating logowiki like interpreter. I have not read the source yet but I think it may be a nice way to show someone how to create a simple lisp interpreter.

Lisp in Todays Embedded World Investigation

I continued my reading about Lisp and also searched the Web a bit more for anything related to Embedded Systems. I think that this is a pretty sad story.

I heard from a friend that I missed ecls in my last post. He said that it is possible to compile Lisp to C with it and then you can crosscompile the resulting C source to any architecture you like. But that simply does not feel right. That is only a hack. You miss the things you want the most (beside Lisp itself) REPL and with it the integrated inspector and debugger just like the profiler and tracer. Also you miss binary upload of functions. Think for yourself. If you do not have that things does development with lisp feel like it should? If you ask me it does not.

So I searched further. I knew that there was someone who developed the triple L, Mars and Venus. I did not know what it exactly was but I knew that it was a lisp development environment for embedded systems.

Looking more in depth in to that, I had to realize that the only thing that exists is the paper L – A Common Lisp for Embedded Systems (pdf format is here) by Rodney A. Brooks and Charles Rosenberg. This paper is telling a beautiful story about a development system that would be the thing one would like to have. But you can not get it anywhere! On the page of Charles Rosenberg you find the pointer that the company IS Robots (that was developing L, Mars and Venus) is now iRobot (yes the Roomba guys). Searching their site does not say anything about lisp though.

The only other person bringing iRobot together with Lisp is Lemindor I have not read all his posts yet but he does not really say anything that helps me neither.

I also asked about the topic in #lisp on freenode but it seems that the overall opinion is that everyone is brewing his own Lisp if he/her wants to use lisp on embedded system.

That is really bad news. I was hoping that there will be something I will be able to base on. The only solution that I see now is to take some common lisp implementation and port it to some embedded system. And when it works start changing it and splitting in parts so that it fits development on embedded systems. (you do not really want the compiler on your embedded system normally an interpreter is enough)

That somehow sounds pretty big and heavy. 🙁

The second solution would be to start with a small Lisp implementation by oneself. When you read Paul Graham’s article Roots of Lisp you get the feeling that it can not be that hard. But still I think that is probably a false feeling. But if I had the power and money to hire some people that are bright enough I think I would attack that. I even know some people that are bright and that would be able to create such thing but none of them would want to invest their time in such a project when they do not get money for that. So there is high possibility that Lisp on embedded systems will remain a dream. 🙁