Sunday, October 02, 2005

3D graphics coding on Pocket PC

3D graphics in your Pocket PC

So I said in my last blog that this blog was going to be about CAB-files huh? Yeah I suppose I did. Anyway, it isn’t going to be about that. Next blog will be about that however.

A year ago I coded a Java Applet on a Apple iBook. Some weeks ago I found that source again and put the demo online Java 3D Applet. And then I decided that I should port that code into C# and make it run on Pocket PC. I had it running in about a couple of hours. Basically all I had to do was correct the syntax. Now I had to run it upon some sort of graphics library. GapiNet sucks really bad, so that wasn’t an alternative. GapiDrawNet however is qute fast, so I used the 30 day demo version to render my whatever my 3D-engine was going to spit in my lap.

I found out that GapiDrawNet didn’t include any good polygon drawers, but only rectangular drawing. I haven’t looked any closer at GapiDraw to see if perhaps there was a polygon drawer in the native lib that just wasn’t mapped into the GapiDrawNet code. So I draw some lines instead, and all was extremely slow. :(

Anyway, I started out on a quest to port my 3D-engine to C++ instead. It was easier said then done. I ended up rewriting the whole code, plus some other code. I also scrapped GapiDraw since it is too expensive for me, and wrote my own graphics lib. Now I have managed to render some cool stuff in real time.


This screen shot is taken from the emulator. I don’t have any mesh reader implemented so I have only tried the cube yet.

Now, let’s do some benchmarking.

HP iPAQ hw6515: Width: 240, Height: 240, FPS: 152
QTek S100: Width: 240, Height: 320, FPS: 110
Axim X30: Width: 240, Height: 320, FPS: 206
HP iPAQ h5450: Width: 240, Height: 320, FPS: 44

Next step would be to optimize it. I think there is a lot that could be done to it. There are a lot of features that I would like to add to the engine as well. Lighting is probably the first thing I will look at. Alpha shading would be nice too. Also I think that I will probably scrap my own GAPI wrapper and go for PocketHAL since it support a lot more features then I will ever bother to put in. Another positive thing about PHAL is that it’s donateware, so even I can afford it :).

When I am satisfied with those things, I think I will go on and write some 2D graphics stuff. I just had to get the 3D out of my system :D.

If you want to get into graphics programming on the Pocket PC then I suggest you check out http://www.pocketmatrix.com/ these guys are sharp.

Oh I forgot, you can download the demo from http://frasse.zapto.org/gouraud.exe, just put it on your Pocket PC (ARM) and run it.

No comments: