Alex@Boberfly home gallery about contact

Archive for the ‘Development’ Category

Mobile Development

Monday, July 12th, 2010

Hi all, I thought I would update my website and I thought I’d share something which I have been working on. I’ve recently ventured into learning game engine design and C/C++ by ripping open an open source graphics engine called Horde3D and by studying how it works, I’ve hacked it to make it run for mobile platforms, for example, onto my Nokia N900 phone. The hardest part was to figure out the small little differences between desktop OpenGL 2.1 and OpenGL ES 2.0, and at first it seemed to be a fairly smooth port, but the hardest thing was that pretty much ES is like an empty shell and a lot of things you need to handle yourself, like making your perspective matrix on the client-end (your program, which is Horde3D in this case) and not the server-end (the actual OpenGL driver, in this case an ES 2.0-compliant driver for the PowerVR SGX 530 graphics processor).

The other issues, they’ve completely stripped it from any “get” functions so that you can’t really dump vertex or texture buffers to the client, so in those situations the code needed to be set up so that it keeps that data in client memory so functions which are dependent on ‘getting’ data can use that as a fall-back. Other differences include a lack of core support for compression formats like the Direct3D “.dds” format so DXTC 1 to 5 are not supported, and Horde relies on .dds support for cube maps, so I needed to port the PowerVR-native format .pvr and the PVRTC texture compression algorithms to get those cube maps to run.

Other odd problems I faced were GLSL shaders didn’t quite port cleanly across, but the main issue here is that ES 2.0 likes to know what precision to set values to save precious resource cycles, and this is especially true for fragment shaders (ie. they won’t compile at all if you don’t specify them).

But then there were just really dumb problems like having semi-complex functions inside GLSL code, I had to convert some functions like lighting calculations to the main function so that it would compile properly, really odd. I have a suspicion that it is something to do with buggy drivers, so I’ll need to test this later on a device with a different brand GPU, like the Nexus One.

I am currently using the Qt toolkit for OpenGL context-creation and input and I’ll probably continue to depend on that library for the Nokia platforms, seeing as though they’re putting their full weight onto that. For iPhoneOS I’ll probably just use their example EAGLview code and modify that and for android I’ll make some Java/JNI monstrosity creation, for another day though.”Pics or it didn’t happen” here’s a test screenshot from my phone directly:

Horde3D Screen