Well I’ve been very quiet recently and that’s mainly down the my mild addiction to playing with Lisp. I been beavering through Let Over Lambda which ia fantastic book on the crazy stuff in common lisp (code that writes code etc) which has been bending my mind plenty.
I’ve also got sick of how the opengl interface works and have gone on something of a spring clean. I’ve made some tools on top of the exisiting common lisp opengl library in order to make it a nicer to work with.
Its definitely not ‘lispy’ enough yet but pushing data into buffers, making vaos and managing programs and their uniforms is much easier now. I’ve got it all up on github though I wouldn’t recommend playing with it yet as I’m damn sure there will be some HEAVY changes before I’m happy with it.
Here is a quick video of me playing around with a small chunk of code which handles the rotation of the objects in the scene. Notice how errors don’t crash the program and I can simply recompile the offending function and carry on. Also note that the repl still works so I can mess around with the camera position from there.
I’m now bored of these little 3D whatchamagigs now so I need to write an importer .obj files so I can get something interesting up on the screen.
Its’ wonderful just to see some of the people involved and their passion. Watch this after you have had your fill of the landing itself.
It really feels like the start of something huge again, the SpaceX docking had me tearing up and this just caps it off for me, Well done to everyone involved, I cant wait to watch the next few years of this.
If you are having problems with embedding youtube videos in Jekyll blogs and getting errors then check out this link.
It turns out that the markdown processor doesn’t like the ‘allowfullscreen’ part of the embed code.
Delete it and the video embeds just fine!
Here is the first little video showing a 3d object translating and scaling while I edit the code and inject it into the running program. This really makes tweaking lots of fun as even the errors can be corrected without having to close the program and recompile.
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.