How To Use Lisp for 3D Game Programming

February 01, 2009Tagged Andi-Land, Games, Videos

I love Lisp. But I've noticed that some areas of Lisp programming are relatively unexplored. In particular, there's not much information online about game development using Lisp. And the situation is even worse for accelerated 2D and 3D graphics in Lisp. Therefore I thought I'd write a short how-to based on my own limited experience on the topic.

First, I use the excellent LispWorks Common Lisp implementation for Windows. (LispWorks is available for other platforms but I have no experience with those.) It has a great Emacs-like IDE and can compile your program into a stand-alone executable. If you don't have to create executables, there's a "Personal Edition" available for free.

Second, LispWorks comes with a set of OpenGL bindings out of the box. There's an invaluable example of how to use them in icosahedron.lisp, also in the LispWorks package. Note that the compilation instructions in icosahedron.lisp are wrong. Use these instructions instead. With the example up and running, I used it as the starting point of my experiments.

Third, I wanted to get some content into my 3D game engine. I used the free and impressively full-featured 3D modeling tool Blender. Blender can export models in the XML-based X3D format. This is convenient since you can use an existing XML parser like XMLS to help load the model into memory.

That's it! With these tools I created the retro-style flat-shaded desert island that you see in the screenshot. Also check out the accompanying YouTube video What would you bring to a desert island?. (Be sure to click "watch in HD" to make the text readable.)

rrr/20081217-01.png

Let's look at some pros and cons of what we've learned:

Summing up, I'd say the advantages easily outweigh the disadvantages ;)