Archive for October, 2008

Image handling on iPhone

October 7, 2008

At first it looks good… but (like most things) when you get into the details, you realize there are some klunky bits. So, I was just looking how to open a png file and it’s dead easy and you can do all sorts of sophisticated transformations, but if – for any reason, you need a simple pointer to the pixel data – you’re boned. It requires you to go around in hoops. And to load a texture you need the pixel data. So, how does Apple do it in their examples? Have a look:

http://read.pudn.com/downloads120/sourcecode/macos/510268/CrashLanding/Classes/Texture2D.m__.htm

yep, they’re pretty much forced to go around in hoops themselves. This must be some pretty inefficient code, though because you have to copy the data twice, once from the file, then from the UIImage to some sort of wierd memory bitmap and then uploading with glTexImage2D.

I already have a tga class, so I’ll just store my images as tga for the time being. It looks like it’ll work a lot better than using the cocoa classes.

Anyways, In the final game I should use powervr compressed images. I have to look into that more, but I assume the data is just dumped into glTexImage2D as it’s read from the file. Powervr compressed images are a dark art. They can only be created via a windows tool and can’t be displayed in the emulator. Quite, ironic that Apple says in their guidlines  “use PVRTC”, and yet there’s no mac tool to create it.

Now it fully works

October 6, 2008

Arrgh. Finally got it working. The whole problem was because my c++ class was a member of an objective c class and objective c clases don’t call constructors. Next stop is to try out a skinned mesh.

Xcode

October 4, 2008

So far, xcode looks really nice. It uses gcc and gdb, however it still manages to be user friendly. The debugger doesn’t handle stl properly by default, but it can be customised.

Right click variable and select “edit summary format”, then whatever you paste in their will be stored and remebered for all variable of same type. For instance, this is for stl:string:

size={(int)$VAR.size()} “{(char *)$VAR.c_str()}:s”

Urrrgh!

October 4, 2008

After spending ages trying to get stlport to compile, I found that the stl was already in the iPhone SDK… but why does it complain “file not found” when you #include string? For some reason all the .m files have to be renamed .mm (even though I was using stl from a .cpp file), otherwise it pretends that stl does not exist.

Mac development for Windows coders is simply horrible. Everything is different and the worse thing by far is the keyboard. Apparently, Spanish Mac keyboards are totally different to Spanish Windows keyboards… apart from all the usual differences, the key that the angle bracket is on is non-existant, the windows key is used instead of the Alt-gr key… except for some characters like the tilda, which is with the ñ key.