Image and thread fun

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!

Leave a Reply

You must be logged in to post a comment.