I changed the GLSprite iPhone SDK example a bit while learning OpenGL ES and it turned out to be pretty slow. Even in the simulator (at worst), so I have to do something wrong, as there are only 400 textured triangles.
const GLfloat spriteVertices[] = { 0.0f, 0.0f, 100.0f, 0.0f, 0.0f, 100.0f, 100.0f, 100.0f }; const GLshort spriteTexcoords[] = { 0,0, 1,0, 0,1, 1,1 }; - (void)setupView { glViewport(0, 0, backingWidth, backingHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0.0f, backingWidth, backingHeight,0.0f, -10.0f, 10.0f); glMatrixMode(GL_MODELVIEW); glClearColor(0.3f, 0.0f, 0.0f, 1.0f); glVertexPointer(2, GL_FLOAT, 0, spriteVertices); glEnableClientState(GL_VERTEX_ARRAY); glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
drawView is called every time you touch the screen or your finger moves on the screen, and tx, ty are set to the x, y coordinates where this touch occurred.
I also tried using GLBuffer when the translation was pre-generated and there was only one DrawArray, but gave the same performance (~ 4 FPS).
=== EDIT ===
At the same time, I changed it to use much smaller ATVs (size: 34x20) and much less overlap. ~ 400 quads β 800 triangles spread across the entire screen. The texture size is atlas 512x512 and RGBA_8888, while the texture coordinates are in the float. The code is very ugly in terms of API efficiency: there are two MatrixMode changes along with two loads and two translations, and then drawarrays for a triangular strip (quad). Now it gives ~ 45 FPS.