Archive for the ‘Uncategorized’ Category

Slowed down

Monday, 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.

Hello world – IPhone, we have liftoff!

Tuesday, 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

Monday, 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

Monday, 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

Monday, 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!


Monday, November 24th, 2008

OK, so I’ve been missing for 3+ months, sorry for the lack of posts.  I suspect there’s almost no-one reading this anyhow.  So far I’ve had 1500+ comments and only one I’ve found that I don’t think is spam – and it’s not on topic either.  As a result I’ve closed posting comments to only registered users.

So what have I been doing?  Well, I played around with the phone game and decided to auto generate a landscape/wilderness to play over.  I got basic terrain generation working using a Perlin noise method (fixed for only using integar maths).

Then I got sidetracked and ported a simple OpenGL game engine and game I have from linux/cygwin to windows native builds using visual studio.  That took a while of fighting the different compilers.  Then I took some time off programming and played some Neverwinter Nights seeing as I’d never finished it the first time around.  That’ll have to wait as I’ve not finished it still!

Then my wife had her semester break so I took some time off to hang out with her – we went and climbed an active volcanoe, swam in the hot and cold springs, did some horse riding in a Del Monte pineapple plantation (pineapples as far as the eye can see) as well as just some general hanging out at the beach.  So I had a really nice month of holiday!

Sadly after this my laptop hard drive started to make horrible clank-grrrr-clank noises and unsurprisingly wouldn’t boot let alone allow me to read anything off it.  I lost the source code to some test applications for my game library (newly ported to windows) and a whole bunch of other things.

More recently I spent a while checking out the iPhone SDK – I think I’m going to be doing some iPhone development as it’s a nice platform, ideal in many ways for gaming.  Also I’ve got an iPod touch so can play and test the games on there.

Lastly I decided to add hardware vertex buffer support to my GL engine (instead of just doing vertex arrays which are held in system memory rather than graphics memory).  To this end I decided to implement a COLLADA importer to get data in.  The reason for this is simple – I should be able to export COLLADA from most 3D artwork apps such as Max, Maya and the open source Blender.

Today I’ve taken the brave step of publishing (however quietly) my first executable version of the game.  Check out this page for more information on the game. It really is only in it’s elemental stages right now though.