I was hoping that someone could help me make some progress in some of the texture tests that I do in OpenGL ES 2.0 and iPhone 4.
I have an array containing sprite objects. the rendering cycle cycles through all the sprites on each texture and extracts all their texture coordinates and vertex coordinates. he adds them to a giant interlaced array using degenerate vertices and indices and sends them to the GPU (I am injecting the code below). All this is done for each texture, so I bind the texture once, and then create my strip array, and then draw it. Everything works fine, and the results on the screen are exactly what they should be.
So, my test test is performed by adding 25 new sprites for each touch with different opacity and changing their vertices in the update so that they bounce around the screen while rotating and running OpenGL ES Analyzer in the application.
That's where I hope for help ... I can get about 275 32x32 sprites with varying opacity bouncing around the screen at 60 frames per second. By 400 I am up to 40 frames per second. When I run the OpenGL ES performance detector, it tells me ...
The implementation of the application is limited by the rasterization of the triangle - the process of converting triangles into pixels. The total area in pixels of all displayed triangles is too large. To make the frame rate faster, simplify your scene by reducing either the number of triangles, their size, or both.
The thing is, I just whipped up a test in cocos2D using CCSpriteBatchNode using the same texture and created 800 transparent sprites and a frame rate of 60 frames per second.
Here is some code that might be appropriate ...
Shader.vsh (matrices are installed once at the beginning)
void main() { gl_Position = projectionMatrix * modelViewMatrix * position; texCoordOut = texCoordIn; colorOut = colorIn; }
Shader.fsh (colorOut used to calculate opacity)
void main() { lowp vec4 fColor = texture2D(texture, texCoordOut); gl_FragColor = vec4(fColor.xyz, fColor.w * colorOut.a); }
VBO setup
glGenBuffers(1, &_vertexBuf); glGenBuffers(1, &_indiciesBuf); glGenVertexArraysOES(1, &_vertexArray); glBindVertexArrayOES(_vertexArray); glBindBuffer(GL_ARRAY_BUFFER, _vertexBuf); glBufferData(GL_ARRAY_BUFFER, sizeof(TDSEVertex)*12000, &vertices[0].x, GL_DYNAMIC_DRAW); glEnableVertexAttribArray(GLKVertexAttribPosition); glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(TDSEVertex), BUFFER_OFFSET(0)); glEnableVertexAttribArray(GLKVertexAttribTexCoord0); glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(TDSEVertex), BUFFER_OFFSET(8)); glEnableVertexAttribArray(GLKVertexAttribColor); glVertexAttribPointer(GLKVertexAttribColor, 4, GL_FLOAT, GL_FALSE, sizeof(TDSEVertex), BUFFER_OFFSET(16)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indiciesBuf); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(ushort)*12000, indicies, GL_STATIC_DRAW); glBindVertexArrayOES(0);
Refresh Code
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuf);
Visualization code
GLKTextureInfo* textureInfo = [[TDSETextureManager sharedTextureManager].textures objectForKey:textureName]; glBindTexture(GL_TEXTURE_2D, textureInfo.name); glBindVertexArrayOES(_vertexArray); glDrawElements(GL_TRIANGLE_STRIP, indicesCount, GL_UNSIGNED_SHORT, BUFFER_OFFSET(start)); glBindVertexArrayOES(0);
Here is a screenshot of 400 sprites (800 triangles + 800 degenerate triangles) to give an idea of ββthe opacity of the layers when the textures move ... Again, I have to note that VBO is created and sent to each texture, so Im binds and then draws only two times per frame (since there are only two textures).

Sorry if this is awesome, but my first post here and wanted to be solid. Any help would be greatly appreciated.
PS, I know that I could just use Cocos2D instead of writing everything from scratch, but do you have fun (and training) ?!
UPDATE # 1 When I switch my fragment shader only
gl_FragColor = texture2D(texture, texCoordOut);
it receives up to 80 sprites at a speed of 50 frames per second (4804 triangles, including degenerate triangles), although the sprite's opacity is lost. Any suggestions on how I can handle opacity in my shader without working at 1/4 speed?
UPDATE # 2 So I grabbed the GLKit View and View controller and wrote a custom view downloaded from AppDelegate. 902 sprites with transparency and transparency at 60 frames per second.