I'm sticking a fork in it. After nearly a year at playing around with this, I think I can finally consider my original goals met.
I haven't added much functionality since the last post, so no new video. Here is a screenshot of the final product:
I managed to get my line based text working, and I did add a frames per second counter in the lower left. The text looks fairly huge in the screenshot, but is at least readable on the Wiz.
You can download the source code/project
here.
The FPS counter may not be wildly accurate. There's some debate on how to get an accurate timer working on the Wiz, I used the standard C "clock()" method, and averaged the results over a second. It's interesting that on the PC OpenGLES emulator the framerate seems to be locked at about 65 frames per second. The Wiz will report values over 300 at times. It's quite possible that it's just not functioning properly on the Wiz.
Getting the font rendering to work was interesting. I eventually did allocate a VBO for every unique character, which made rendering of the text much faster. It seems that the Wiz is very sensitive to geometry uploading, you will absolutely kill performance if you are uploading geometry every frame.
One trick with the text was that I had to explicitly disable GL_TEXTURE_2D in order to be able to color the lines properly. I never explicitly enabled it, but some of the other texture mapping commands must turn it on behind your back. Unfortunately the Wiz OpenGLES hardware does not support antialiasied line drawing, so that font is pretty rough looking.
Another issue I ran into with the VBO code was that you have to make a call to glVertexPointer and glTexCoordPointer every time you bind to a new VBO. This seemed contrary to the examples in my OpenGL book, and it took quite a while to figure out was happening. Luckily all the activity with iPhone OpenGLES development has made it easy to look up OpenGLES issues via Google. The iPhone hardware seems to have a lot of the same quirks.
When switching to using VBOs, I also took the opportunity to interleave the vertex and texture coordinates. Previously I had used two arrays, one for vertex information, and one for texture coordinate information. By combining them into one array I simplified the code, and in theory made the rendering faster.
I did translate all the floating point math over to fixed point math. This includes a sine and cosine lookup function, along with an ATan2 style function. After looking around the web a while, I settled on the Cordic method for solving ATan2. It seems fast enough.
In order to compile this on the Wiz, you'll need to download Pickle's pre built OpenGL-ES development package
here. You'll need to install the libwizGLES.so libary from that archive into your environment, along with the include folders. You'll also need to modify the makefile to point it to your toolchain. I never figured out how to get this to compile under the old Gp2x tool chain under Windows. I used the Open2x-Wiz toolchain instead, which seemed to play nicer with the shared libraries.
To run this on the Wiz, download and install the OpenGL drivers onto your Wiz from
here.
Here is the final compiled version for the Wiz:
http://www.blastriot.com/tutorials/tutorial8c.zip
I'm not going to continue public development on this, although I'll probably take this as a base and start working on a real game.
There are a few obvious places for improvement:
- Add Sound
- Make game logic frame rate independent
- Add collision with environment
- Improve Wiz control scheme
Thanks to everyone who contributed! If anyone is looking through this and has questions, let me know!