Remote work – is it going to happen?

March 9th, 2009

So I’ve been searching high and low for some remote work for a while now.  Sadly I’ve not had much success, despite being able to work for a pretty good discount compared to folks in the west.  I suspect folks are going back to basic with the world economic situation.

My family life has changed as we now have a baby on the way!  This does mean that I need to take life perhaps a little more seriously than I have.  Much as I’m enjoying playing around with my engine and trying to drum up some work and income, real responsibilities and deadlines are starting to loom ever closer.  So we’ve decided that for now we may have to put the dream on hold – or just change the dream.  So now I’ve officially started looking for in house positions around the world.  Ideally I want to find somewhere that’s either relatively local to here in the Philippines or has a decent Filipino ex-pat community as I want my wife to be happy and feel at home, especially as she’s expecting!  Also of course I’m looking for something that is a great opportunity with a good company too.  Ideally I want to find something that fills all three requirements!

So the new dream is to be able to build a stable and happy home environment for our family to grow in!!!

Slowed down

March 9th, 2009

So it’s been a while, this last month seems like I’ve not got much done.  I spent a few days battling the flu and a couple more getting sucked into watching Alias of DVD.

Coding wise I also started to work on a one size fits all serialization system.  I had the following goals:

  1. In final production code it needs to be fast.  Ideally load in a single block of data, fix up pointers and run.
  2. It has to be generic enough to handle any kind of data (which messes with (1) as certain data needs to be uploaded to gfx cards and so has to be streamed and copied into gfx memory.
  3. Needs to be easy to debug, I want a human readable form so I can see what’s going on in the files.  Considered XML but really it’s over the top for these purposes.
  4. Also needs to be able to stream load in for development purposes so version changes can happen and data packages conditioned for different platforms.

All in all a whole set of noble goals which I think I’ve just about fulfilled – or can fill in the case of (2) with a simple extension.  The versioning framework is also there but not yet fully implemented.  I’ll come to that as I need it and can build the test cases as the implementation comes.  Now it’s time to move onto using it and some more fun stuff!

However it took me a long time to get to where I wanted to be along with a couple of re-writes of various substructures.  Still now I’m pretty happy.  About the only thing I’m not supporting that I want to is loading/saving of base class pointers to child objects.  To do this I’m going to need some kind of run time analysis to find out if a pointer is a type of (in theory it could be compile time but compilers don’t support an istypeof expression as far as I know).

Other than that I messed around with a simple finger painting app for IPhone for about a week.  I got rendering to texturing working under GL/GLES as doing the required alpha blending on the CPU was way too slow.  I also got some simple GUI elements working together.  However to extend that I’d like to build a GUI editor that will help me to build such functionality – but I needed the serialization stuff to work first!  Still I’ve build the fingerpainting interface, a friend/partner is planning on building some network code so we can launch a collaborative IPhone fingerpainting app.

More IPhone fun

February 6th, 2009

After getting things working on the IPhone I’ve been messing around with a series of further technologies on there.  I had to re-work my assert code as it only worked on a singe thread (oops).  In the end I discovered the way to do this is using Objective C’s selector messaging and then I can run a message on the main, event handling thread.  This reminds me of how in the Java/Eclipse SWT you can add blocks of code to be run later in the same messaging thread.  It’s very cool anyway and makes multi threading headaches appear to disappear somewhat.  I’m starting to really enjoy Objective C as there is a lot of expressive power.  How optimally some of these things compile I don’t know.

After fixing up assert for multi-threads I added in touch and tilt/accelerometer support.  At the moment my game engine simply polls for different input states so I’ve mapped these to the polling kind of architecture.  I’m wondering how best to do this for gesture control though.  I think it’s be nice to be able to define a gesture in some kind of ‘gesture description language’ and then just poll for that gesture having been completed as a single input.  This makes it easy to map inputs across platforms.

For example the Plane Game it would be nice on a PC to be able to drop a bomb by pressing b.  On IPhone though the same could be accomplished by a downward stroke on the touchscreen.  This would mean the underlying game code would be the same – the input library (and it’s configuration file) can handle all the mapping.

I should be producing another version of the Plane Game pretty soon with some advanced features. I’m working towards producing an IPhone version at some point. Also it’s been brought to my attention that the current windows version required the GNUWin32 dll’s for zlib, png and jpeg support. The new version will do away with those requirements.

With that in mind I’ve done some more COLLADA work, I can now import properly regardless of the up axis and once pulled in I’m indexing and then post transform vertex cache optimizing and vertex memory location optimizing my meshes. I soon hope to be able to save out a mesh imported from COLLADA and load it into the game to replace some of my sprites. It will be a nice stepping stone for the library!

Hello world – IPhone, we have liftoff!

January 13th, 2009


I’ve been up to a whole host of fun things recently.  I guess the most exciting for me was the completion of porting my game engine over to the IPhone simulator.  It took about 3 days, a far amount of which was figuring out how to support multiple platforms on XCode and building some wapper code.   I’ve stepped away from SDL and am using my own wrapper on the IPhone.  So I had to do some Objective-C as well to build the wrapper code.

I think I actually spent longer working on the assert functionality then anything else.  For a nice assert you need some way of throwing up a modal dialog box.  That means you fire the dialog box and wait for it to return, you don’t want to carry on until it’s finished. 

I was all about ready to go forth and kick off a thread for the query and then block for that thread to exit when I found The Bunny’s IPhone Development FAQ. Wonderful resource! I’d already figured some of that out and was spawning my own thread for the main game loop and had figured out the OpenGL buffers and context needed to be created in the application/event handling thread and then passed over to the game thread. However the wonderful information of exposing undocumented private features of the UIAlert class did the trick!

That is something I do like about Objective-C, you can define your public methods in the header file, but private stuff can be hidden away completely. Very nice abstraction and information hiding there!

TGA import library

December 29th, 2008

Well sooner than I expected I got around to cleaning up the code I mentioned in my last post and publishing it under a BSD license. It’s all there in that article, enjoy!

More image fun – Targa import

December 29th, 2008

Another project I’m working on is adding some COLLADA import functionality to the library, which is going quite nicely. The end goal is that I can knock up some assets in blender and use them for some sample material. So far I’ve got triangle mesh import working, untextured materials and point lighting working. The next step was textured materials.

The first sample I came across however uses TGA’s as the texture. This is a pain as my library only supported PNG and JPEG. So being my usual lazy self off I went to search for a TGA import library that I could wrap around. Sadly I found things very lacking – but I did find the 2.0 specification document. Feeling brave I decided that actually I could roll my own importer pretty quickly. Turns out it was slightly more tricky than I anticipated but not much!

I will write an article about the choices I made and include a simple implementation of this shortly. My implementation covers the whole 2.0 specification, as best as I can tell, indexed (palletized), true colour and black and white images supporting run-length encoding. However I’ve found it difficult to get hold of a library of sample images so in the end have made my own. I’ll make those available too shortly, ideally (given time) I think I’ll clean the whole thing up a little and publish the library as a whole.

The only thing it doesn’t yet cover is I read something about Huffman compression but I guess that’s a later extension.

Image and thread fun

December 29th, 2008

So once I got all my cameras and matrices working as they should my target was to render a spinning earth textured with some images from Open Street Map. This worked great but what I really wanted was satellite imagery to make it look really cool. I find Google’s terms and conditions confusing and in a number of places I read that pulling down individual tiles is prohibited. Luckily I found the Open Aerial Map project that does seem to allow me to do whatever I like with the images.

My application is multi threaded. I have the main drawing thread, a thread than handles multiple downloads (wrapping the curl library) and then a couple of threads that take the images, decompress them and upload them to the graphics card memory. As I’m using OpenGL accessing the context from multiple threads was interesting and turned out to be different on my different target platforms (XP/Linux/OSX). Still I got all that working although I want to natively port my windows thread library rather than using a pthreads wrapper and I also want to use multiple opengl contexts on platforms that support it rather than the windows way of sharing the same context).

Anyway all this worked great with the PNG images from Open Street Map. What became a major headache however was when I started to pull down JPEG images. My image library wraps The Independant JPEG Group’s library which it turns out is not thread safe. I’ve had to run all JPEG decompression serially which I’m not so pleased with. As the IJG’s library was last updated in 1998 I’m thinking I either need to find an alternative library, write my own or perhaps make the IJG’s work thread safe. I’m thinking to make it thread safe the statics need protection – either by making them thread local storage, or preferably by stashing them all into a context that I pass around.

Here’s a quick screen shot of my globe:

A screenshot of my textured spinning earth application

Some of the blurriness is down to the way I compressed the PNG. You will see the nasty texture seams (ouch). Still I know what’s causing them and also how to fix it, but that’s a job for a little later, along with a whole load of optimization and a free camera to allow me to pan in, zoom around and such. Also I want to add a star field in the background, light the globe, ideally using the lighting to fade between a day and night image would be very cool but when zoomed in I’m not sure how we’d get the resolution, add an atmosphere and different material properties (water, ice, forest, sand etc). I’m sure I won’t get it all done but there’s plenty of things to play around with!

OSX Port and matrices

December 15th, 2008

Now I’ve got a working source control solution up and running it’s made it much easier to port my code base around to different operating systems as I can pull it down and play with it without having to copy the entire thing around.

So after having imported my sources on windows, I got everything running under 64 bit ubuntu (no problems there really, just hacked my makefiles to detect the os/host type rather than editing it by hand everytime). After that though the challenge I’d set myself was to port onto OSX. Now I’m not to familiar with OSX (yet) so this was probably more of a challenge than it should be.

I struggled with simple keyboard shortcuts not working as expected and the idea of the application menu bar always being at the top of the screen (wasn’t the Amiga OS like that though, I’m too old perhaps to remember). I also found it odd that I could close all the open windows of an application but it would remain be open.

My first problem was finding a nice text editing program for hacking around on text files. Under windows I use and would recommend notepad++ for this purpose. However it took me a while to find a suitable replacement for OSX. In the end I plumped for jEdit which Java based and so in theory I can actually use across all my environments if I want. Whilst jEdit worked fine I also wanted to be able to launch it from within the bash terminal shell, for example by typing jEdit ~/.bashrc and it launching the editor pointed at the correct place. This turned out not to be as easy as I’d have liked because of the way apps work. I’ve written an article about launching OSX apps from the command line if anyone is interested.

After getting all this working I played around with XCode and managed to import my code base and after a little struggling got it all to compile. As my library wraps SDL for it’s OpenGL, window management and input code it wasn’t even too hard to get my PlaneGame” up and running on OSX too. Next step is an iPhone port of the library!

In the meantime though I also have another little project I’m working on. This one requires full 3D rather than the 2D (built on top of 3D) approach that PlaneGame is currently using. In what should be a simple process of setting up a camera I ran into some matrix maths problems that I just couldn’t seem to figure out. I finally cracked it – I’m used to DirectX’s row major matrices whereas OpenGL uses column major matrices. However because GL’s vectors are column vectors and DirectX’s are row major the linear representation in memory is the same. Once I start multiplying those vectors together though all bets are off though as they result in transformations being applied in different orders. Now my matrix library is far more robust – I can request matrices and vectors to be row/column major and still have everything work as expected.

Setting up source control on Host Monster

December 2nd, 2008

I’m collaborating on a small project with a friend that means we’d like to share some source code around. As I have dynamic IP and don’t have a server at home always on the Internet I thought my web space on Host Monster (incidentally where this is hosted) seemed to be an ideal place to host this. My initial thought was to set up a CVS repository. CVS appears to be installed on my Host Monster account already – brilliant. However it seems that for anyone to access it they would have to have root ssh login to my account. Not that I don’t trust my friend but I don’t really want to start giving away root access to my web space.

So I thought about looking for other solutions – one that came to mind is svn so I looked into that and found this informative post on how to do what I wanted but with subversion, albeit on a different web host. I also found a helpful thread about how to install Subversion on Host Monster. Now I’m a newcomer to subversion although I know as a user it works in almost the same way as CVS.
Sadly it seems that there is no way to do this with CVS that I could find.  It may have been possible by tunnelling a pserver connection through ssh – however it seems the cvs install doesn’t allow even local pserver connections.  Finally I put all this together and thought I would share it with the world by writing a new article Adding a safe multi user subversion repository.

Problems with opengl drivers on AMD/ATi

November 24th, 2008

So I decided to check the first version of the Plane Game on some different machines. I know it works on Windows/Linux on my main PC and on my laptop. However since the laptop hard drive died I’ve not run it on there. Also I’ve a second computer here, running an ATi gfx card at the moment so I though I’d try it on there.

It wouldn’t run on the ATi 2600 PRO card at all. I figured out the problem was that there were openGL extensions missing – specifically the ones to let me load and bind shaders. The shaders don’t do anything fancy and I’d only implemented that to check I could load shaders on OpenGL. Anyway after much digging I discovered that GLView reports that my card only supported open GL version 1.1. Which is odd as it’s a DX10 class card and should do GL 2 easily. I finally figured out the problem, GLView also listed the OpenGL driver as being nvoglnt driver which after a little help from Google I discovered was the Nvidia OpenGL driver. So I went to add and remove programs from the control panel and discovered I’d got 2 different versions of the Nvidia drivers installed (one ASUS branded and one generic NVidia forceware). When swapping 3D cards around doing compatibility testing I’d forgotten to remove them. Although it didn’t stop D3D from working it had messed up GL. I removed these and the ATi drivers for good measure, rebooted and installed the latest ATi drivers and now all is good… OpenGL drivers for 2.1 – phew!