Let’s take a diversion into the world of OpenGL, specifically the implementation of OpenGL that lives inside an Android powered device. So, OpenGL ES 1.0 then. I’ll be learning about orthographic projection to begin with, simulating a 2D display using 3D hardware acceleration.
What follows in the next series of posts is my own notes on learning OpenGL. Some of it may be kludgy, some of it might be hideously inefficient and some might be plain incorrect. If you’re a hardened game dev who can calculate matrices in their sleep, your assistance is welcomed.
I’m assuming a lot of iPhone OpenGL ES will be relevant too.
When trying to figure all this out, I was frequently finding nothing but a black screen appearing. Setting up a working OpenGL context requires many lines of code, and any that are wrong mean things won’t work.
The Android 3D game tutorial is a good place to look at working code.
I found the following things useful:
- If you can’t see anything, try doing
glTranslatef(1.0f,1.0f,-1.0f)
to translate away from the objects (or to translate the objects away from you, depending on how your mind works)
- Use
glOrthof(0,width,0,height,0.01f,100.0f)
to make the OpenGL view match the screen resolution
- Broken OpenGL code will run, but produce incorrect output
- If the code crashes, check the vertex/colour/index buffers are correctly defined. Crashing code is not an OpenGL problem
- The OpenGL and OpenGL ES specification documents will tell you how to use OpenGL, but they won’t teach you how to write OpenGL software
Oh, and since this is a post about OpenGL, where would we be without a link to the NeHe OpenGL examples. These ones are for Android.
So far I have a triangle on the screen, and can glTranslate() it around the screen. Now to learn some more.

