At the moment i've got 114 triangles being rendered. I only have a 192kb texture being loaded. Also I'm running it in release mode on version 2.2.1
And performance on the simulator is great but on my iPod touch is absolutely unusable.
My drawView method is very simple(bellow)
My drawTexturedQuad method (bellow)
The update method being called on the player just increments his position for test purposes.
I've also tried reducing the nested loop to run only 4x2 instead of 4x4 and the performance is still shocking on the iphone.
I've also tried lowering the update speed from 1/60 to 1/30 and shrinking the viewport but still no major gains in performance.
Am I being an utter Muppet? (this is my first iPhone app and my first OpenGL app) or is the performance that bad?
I may have sussed this,
I tried rendering the floor in sets of tiles with multiple draw calls then as one big triangle strip in a single draw call and got an immediate performance boost.
Looks like I need a way to build my level, then render it in a single draw call.
Though any other performance tips would be great.
And performance on the simulator is great but on my iPod touch is absolutely unusable.
My drawView method is very simple(bellow)
Code:
-(void)drawView {
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glViewport(0, 0, backingWidth,backingHeight);
/***********************************************/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
player->getRotaiton(playerRot);
player->getPosition(playerPos);
glRotatef(playerRot[0], -playerRot[1], -playerRot[2], -playerRot[3]);
glTranslatef(-playerPos[0],-playerPos[1] , -playerPos[2]);
for(int x = 0; x < 4; x++)
{
for(int y = 0; y < 4; y++)
{
if((1 & currentRoom[x][y]) != 0){
[self drawTexturedQuad:northWallVerts texture:dungeonTexture textCoords:wallTextureCoords];
}
if((2 & currentRoom[x][y]) != 0){
[self drawTexturedQuad:easthWallVerts texture:dungeonTexture textCoords:wallTextureCoords];
}
if((4 & currentRoom[x][y]) != 0){
[self drawTexturedQuad:southWallVerts texture:dungeonTexture textCoords:wallTextureCoords];
}
if((8 & currentRoom[x][y]) != 0){
[self drawTexturedQuad:westWallVerts texture:dungeonTexture textCoords:wallTextureCoords];
}
[self drawTexturedQuad:ceilVerts texture:dungeonTexture textCoords:wallTextureCoords];
[self drawTexturedQuad:floorVerts texture:dungeonTexture textCoords:dungeonTextureCoords];
glTranslatef(0, 0, -nsStride);
}
glTranslatef(ewStride, 0, (nsStride*4));
}
player->update();
/***********************************************/
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
My drawTexturedQuad method (bellow)
Code:
-(void) drawTexturedQuad:(GLfloat*) quad texture:(Texture2D*)texture textCoords:(GLfloat*)textCoords
{
glVertexPointer(3, GL_FLOAT, 0, quad);
glTexCoordPointer(2, GL_FLOAT, 0, textCoords);
if(texture) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.width, texture.height, 0, GL_RGBA, GL_UNSIGNED_BYTE,texture.spriteData);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
The update method being called on the player just increments his position for test purposes.
I've also tried reducing the nested loop to run only 4x2 instead of 4x4 and the performance is still shocking on the iphone.
I've also tried lowering the update speed from 1/60 to 1/30 and shrinking the viewport but still no major gains in performance.
Am I being an utter Muppet? (this is my first iPhone app and my first OpenGL app) or is the performance that bad?
I may have sussed this,
I tried rendering the floor in sets of tiles with multiple draw calls then as one big triangle strip in a single draw call and got an immediate performance boost.
Looks like I need a way to build my level, then render it in a single draw call.
Though any other performance tips would be great.