Learning OpenGL in lisp is pretty cool, its my first lisp project, first time using opengl and first time learning the workings of a foriegn function interface. All this makes for hairy debugging as its always nice to learn from some familiar terortory so you have a rough idea, when something goes wrong, whether it’s you cocking up or some other bit of code.
This time however,no such luck.. Each problem has the potential to be me missunderstanding the tutorial..or OpenGL…or the C++ code I’m translating from…or the lispy abstractions around the c library provided by cl-opengl! But there is progress… I’m up to tutorial 5 in the awesome modern OpenGL tutorials at ArcSynthesis.
It doesnt have a depth buffer yet so the smaller object is actually further away than the apparently larger one, but that in the next tutorial!
This is really a ‘note to self’ but if you are learning a language and have experience with other, then the Rosetta Code really help when you hit that problem when you yell “THIS IS SO EASY IN -insert language here-!”.
While trying out Common Lisp and I keep coming up against little problems that I would happily tap out fluently if I was coding in Python but which in Lisp leave me scratching my head. Rosetta Code has helped a few times now and yet I keep forgettign about it…Hopefully now I’ve wirtten this it may stick!
As with anything I want to learn, it seems I need a project to drive me. The project is often WAY above my ability but it makes for a very motivating goal to keep in mind while trudging through the more tedious/mind-braking parts of whatever I’m studying.
The project I have in mind with Lisp is a live game coding environment. I listened to an awesome talk on FLOSS Weekly a little while back on Overtone, a live music coding environment, written in Clojure. If you are struggling to see how this would work have a look at this video.
The real feeling I get here is that, just like in music, coding can have composing and jamming. What I mean is that programming (to me at least) can often feel like I’m composing, I am primarily solitary, noodling around with little ideas and bits of code until I get a good idea of where I’m going and then I need to plan and write so I can eventually present what I have made.
Jamming has the result visible from the start, and because what is happening is immediately viewable (audible) other can chip in and shape the result, even if they are not playing themselves.
I want to do this with code, specifically visual programming and games.
These ideas obviously aren’t new, they have been said plenty of times before, and there have been strides in the direction. Every time the speed of iterating in a language is improved, we are one step closer to this goal. Recently a fantastic guy called Bret Victor gave this amazing talk where he explained that “creators need an immediate connection with what they’re creating” and demonstrated it beautifully with (amongst other wicked demos) a 2d platformer where the changes he made in the code were immediately reflected in the game. This seems cool enough but the result of this immediate feedback is that he could ‘jam’ with the code, he could make changes with worrying about crashing out of the demo and just explore the ‘what ifs’ of what he was writing.
Now while Lisp doesnt implement this at all it does have one feature that is very nice, you can compile the code for a single function and add it to the running program. This also means you can redefine the code you are running while it’s running which is a great first step.
Just a minute ago I was able to load up the OpenGL tutorial I was working on which involved a triangle moving in a circle (yup I’m starting from scratch!) and, just by virtue of the code being written in lisp, I was able to change the colour, path, speed of the triangle and immediately push the changes in the code into the running program and see the effects they had.
I could also see how things broke if I messed with commands in the wrong way, and thanks to how lisp handles exceptions I could undo the change in the code, push the change into the program and tell the program to continue using the new code, and in only couple of seconds. I must admit, it felt fantastic!
I’m putting at the work I’m doing on github although there’ not really much there yet, I will post here with videos and pics as more takes shape.
Take care, happy jamming!
If you need to quickly find out the version of OpenGL you have along with the version of GLSL you can use then run the following at the command line.
glxinfo | grep -e "OpenGL.*version string"
Remember that if you have 2 graphics cards that you will need to be aware of which one it will be checking. For me that meant running:
optirun glxinfo | grep -e "OpenGL.*version string"
As I am using Bumblebee to enable use of the optimus graphics setup.
For those who are playing around with Jekyll and would like to be able to quickly create and publish posts within emacs then you may want to check out jekyll.el.
I’ve been trying it out and it means that regardless of what I’m working on, when the idea for a post comes into my head I can C-c b n (‘blog new’ I assume) jot down the idea and carry on.
For anyone who needs to be able to unload ideas from their brain in order to focus on the job at hand this is a real boon.
When you have finished the draft it’s C-c b P (blog publish) to move the post from the draft folder to live. I can then preview it and push to the world via git.
Currently I’m neglecting my other unfinished projects in favour of playing with OpenGL in common lisp.
I’ve been getting my head around lisp for a couple of months and really needed some kind of project so I could test out some of the things I had been reading about. Making some kind of visual extension to the repl sounds perfect and I’m curious to see how fast you can iterate when making games with in-line compilation.
There’s obviously a tonne of maths involved and trying to whittle down what is neccessary from all the articles online would be daunting if it wasnt for the fact that Ogre exists and is open source. I just cant get over that… Every time I open it I get the rush knowing that I can read this thing and use the knowledge I gain to go make something new, and that that is encouraged.
Well anyway thats my little vent, if you are looking at getting into games programming and you have a some programming knowledge under your belt then I heartily recommend going and reading some of their code, it’s very clean and coupled with a good book (I’m reading Game Engine Architecture at the mo) it can really illuminate how to get things done in real life.
Oh and don’t worry if you don’t know c++, neither do I…But if you have good google-foo and are used to programming you won’t have to much difficulty.
Ok so I am currently moving away from WordPress as I really would like to be able to edit my blog fully offline and preferably have it managed via some dvcs.
So this is it, my new home, hope you enjoy it!
I'm going to be saying this for at least another couple of weeks. I'm in that wonderfully scary bit where I have tip throw the switch and watch for the magic smoke. Wish me luck!
Just tested all the motors and extruded my first blob of plastic. Nothing so fine as a real print yet but also, save a small issue with some wire insulation smoking, no problems.
Next I need to have a good dig into the process of calibration and setting things up for a print.
I’ll keep you posted!
Nearly ready now, there is a meeting of the thames valley reprap'ers this tuesday so I'm hoping to take this there and get some advice on the firmware side of things.