Friday, 8 March 2013

Raspberry Pi and OpenGL

So it has been two weeks since my last blogpost, so much for keeping weekly updates. Couple of reasons why I have not kept up: First, I was working on my graduation which picked up some more steam. Previously I had been running experiments which gave me some off-time to work on other project. Secondly, I have been having some doubts about the project as to what I want to do with it. This keeps happening often with me; once the fun stuff is done I seem to lack motivation and most of all, purpose. I think I need to have better goals and a better time window/planning. Finally, not all time is wasted. I recently got my hands on a Raspberry Pi and was messing about with OpenGL ES on the PI. The OpenGL work that I have been doing is very interesting and is closely related to game development.

For those who do not know what a Raspberry Pi is, it's a small credit-card sized board that has a little ARM processer and a GPU which is powerful enough to render 1080p video. It has a HDMI out and all the basic inputs you need like USB and Ethernet. Since it hook up to a TV and can stream video it makes it ideal for configuring it as a media center. There is a XBMC distribution for the Pi, but to be honest I have tried XBMC and didn't quite like it so much. It has too many features (not really a problem, but this makes it more complex than needed), doesn't look all that good and has a counter-intuitive user interface. I simply want a wrapper around my file system so I can select what I want to watch. I already gave this a go before with PyGame and made a design for it, but this seemed to give poor performance because it didn't use the GPU. While fun at the time, it got shoved in the freezer because it was not usable.

Media center design
So, I have spend the last couple of week working on getting OpenGL working on the Pi and trying to see if I can get something presentable. This little project started when I came across a forum topic about OpenGL and the Pi. Somebody there made a github project which contained some of the work he had been doing with OpenGL ES. When messing around for a bit I noticed the code wasn't really all that readable and covered more than what I wanted to do with it. So I extracted what I needed and made it a bit more manageable for me. The result is a small 2D framework for rendering sprites; it can also do clipping masks and animation. I also made a texture loader which can run in the background for better performance. There are still some quirks where the texture data seems to be missing (render white), which is most likely due to a garbage collector or something which still needs to be looked into. Far from done, but overall I think I already have something workable.

At the moment of writing I can get around 40-60 FPS with quite a bit of background work (crawling file system and async texture loading). I think this isn't too bad, seeing I am using Python as a wrapper around the native code from the .so (lunix version of a dll) file. I have included a small video which shows the actual think I have now. Possibly I can extend this to run on the desktop and it might even use it to create games with it. If you are interested, send me a message (either on reddit, facebook or twitter)

Next week I hope to come up with a better plan on what I will be doing with the AGame. I have some ideas, but I need to work them out further, so until then.