Simple Shoot-em-up Development


satacoy said:
After some frustration fighting with OpenGL on the Wiz, I finally got Tutorial 8 running on the actual Wiz hardware:

Pickle's OpenGL/SDL archive topic finally got me compiling properly, from that point it was fairly trivial to get things running properly.

OpenGL doesn't seem to be blindingly fast on the Wiz, there's obvious slowdown when more than a few rockets are fired. There also seems to be some blending differences between the emulator on the PC and the actual hardware. You can see all kinds of strange transparency artifacts on the Wiz.

I've still got a little code cleanup to do, I'll post it here once it all looks good.

Thanks again Pickle!

Nice looking good! :)
 
Last edited by a moderator:
I've made a few changes that have sped performance up a bit.

.

You can download the Wiz binary here:

http://www.blastriot.com/tutorials/tutorial8b.zip

Extract it to a folder, and use the launcher to launch tutorial8.gpe. Use the "Select" button to exit, the shoulder buttons to rotate, and the "A" button to fire.

I switched to using Vertex Buffer Objects (VBOs), which made the biggest difference. Instead of uploading the simple geometry for each object on each frame, I upload them once during creation of the first instance of an object, then reuse that geometry each frame.

I also turned off the bilinear filtering, and switched back to GL_NEAREST. This made a noticeable difference, although not as drastic as the VBO change. I also fixed a few issues with how the particle systems fade out, which removed some of the weird discoloration of explosions.

I turned of the text rendering, it looks like crap, and for some reason it really slows things down. I suspect that it's due to not using VBOs for the vertexes for the characters. I'll probably switch to a bitmapped font approach at some point, I should be able to use VBOs for that pretty easily.

I think there's still plenty of room for performance improvements. With 5 bad guys on the screen at once, firing rockets like crazy, there is still some slowdown. I get a pretty consistent 90 frames per second until too much starts happening, then it drops way down to ~40 fps.

The main issue right now is the strange lack of total transparency for all my objects. It's mostly noticeable on the explosions, you can definitely see the outline of the bitmap. This doesn't happen on the PC. I'm not sure at this point if it's due to me doing something wrong, or an issue with the OpenGL driver.
 
Last edited by a moderator:
satacoy said:
I'll probably switch to a bitmapped font approach at some point, I should be able to use VBOs for that pretty easily.
If I remember correctly, openGL|ES doesnt allow bitmapped fonts (or anything else for that matter, i might have just misunderstood the pdf though)
satacoy said:
The main issue right now is the strange lack of total transparency for all my objects.
Have you tried using glAlphaFunc() ?
 
Last edited by a moderator:
zacaj said:
If I remember correctly, openGL|ES doesnt allow bitmapped fonts (or anything else for that matter, i might have just misunderstood the pdf though)

There's no built in support for bitmap fonts, at least in the ES variation. I was planning on rolling my own, applying font decals to polygons.

zacaj said:
Have you tried using glAlphaFunc() ?

I have not, thanks for the pointer. I hope it's something simple like that. I was starting to go down the road of trying to understand glTexEnv, I'll give this a shot instead. Looks much simpler!
 
Last edited by a moderator:
Oh. I assumed that was what you were doing before. How were you doing fonts?
 
zacaj said:
Oh. I assumed that was what you were doing before. How were you doing fonts?

I'm re-using some line based fonts from BlastRiot. I might still tweak that code so that it's not constantly recalculating and submitting the vertexes.
 
Last edited by a moderator:
Runs great on firmware 1.1 satacoy. The screen's pixel density is so high that I doubt there's any visual downside from using nearest neighbour filtering.

Alpha blending seems to be quite speedy too, finally one less limitation to worry about :)
 
Alex. said:
Runs great on firmware 1.1 satacoy. The screen's pixel density is so high that I doubt there's any visual downside from using nearest neighbour filtering.

Alpha blending seems to be quite speedy too, finally one less limitation to worry about :)

Yeah, the difference between the two filtering methods is hard to detect when looking at it on the Wiz.

I've been hoping for almost-free alhpa blending and rotation/scaling for a long time now. It's nice to finally be at that point.
 
Last edited by a moderator:
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:

Tutorial8c.jpg


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!
 
This is really excellent .. I'm looking forward to checking this out in depth next Wiz-hacking session .. thanks for doing this project!
 
I tried to run the example but I'm getting: symbol lookup error: /lib/libopengles_lite.so: undefined symbol: _Z27GLESOAL_GetDisplayDirectionv
How to fix that?

edit: Nevermind, now it's working (didn't change anything though). Thanks again for the tutorial!
 
Back
Top