"Simple" OpenGLES (2D) efficiency question .. for OpenGLES experts!

fattoh, one thing I noticed that I don't think anyone mentioned. If you're in 2D, what are you using 3D triangles? I'm not sure if this will make a noticeable difference, but you can specify strictly 2D triangles. In 2D, each triangle data only needs 2 floats per vertex then, and to set up your vertex pointer, you just switch the following:

Code:

glVertexPointer(2, GL_FLOAT, 0, happyVertices);

You should also consider interleaving your data. If you just have position and texture coords, then this means you set up a struct such as:

For completeness and the sake of anyone reading this in the year 3000 and trying to work out OpenGLES. I forgot to mention that:

if you use "method B", and indeed if you doing more than one sprite (say, a small number), and you call that draw method one time for each sprite you are doing...

of course you'll have to wrap your translate, rotate etc. drawing code inside a pair of push/pop statements to push and pop the matrix situation on and off each time. (otherwise all your individual positions will sort of add together during the frame construction, of course.)

I have no idea if glPushMatrix(), glPopMatrix() are FAST or not.

(Again, the overall idea of using MethodB if you have LOTS of sprites is probably not the way to go, so you'd only be using a handful of sprites anyway, so it likely doesn't matter much.)

alerus Wrote:fattoh, one thing I noticed that I don't think anyone mentioned. If you're in 2D, what are you using 3D triangles? I'm not sure if this will make a noticeable difference, but you can specify strictly 2D triangles. In 2D, each triangle data only needs 2 floats per vertex then, and to set up your vertex pointer, you just switch the following:

Code:

glVertexPointer(2, GL_FLOAT, 0, happyVertices);

You should also consider interleaving your data. If you just have position and texture coords, then this means you set up a struct such as:

Interleaving really only matters when you are submitting a big array of vertexes at a time. I usually just do it for readability. By using structs you can do something like vert[4].vertex.x or vert[3].texcoord.y instead of trying to figure out the correct index offset by hand.