Currently a bit busy but if my 10second overview of it is correct, you are changing states A LOT _every_ draw loop and thus killing your performance already. I'm not sure is it the root of the problem but a really good place to start looking.
First of all,
minimise state changes. Meaning don't call these every loop:
- Code: Select all
//Enable the vertex, texture and normal state
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
//Disable the client state before leaving
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
Instead, call enable client state once in the initialisation when you get open gl handle and that's it. Do not keep flickering back and forth without any reason. You are drawing from vertex and texture arrays all the time so I see no reason to disable them.
Enable once in init. And same goes for gl.glEnable(GL10.GL_TEXTURE_2D); If you don't disable the state, you don't need to tell OpenGL every loop to enable it. It's enabled already.
OpenGL's states stay on unless turned off. So.. Try those out.
You need to remember that unless you turn off opengl's state, it will stay on and this is a fundamental thing to crasp and understand compeltely when developing with OpenGL. Same goes for the textures. You should store all the textures in ONE BIG texture, instead of telling OpenGL to swap texture every side of the cube... This way you tell OpenGL once that alright, use this texture, and using texture coordinates you pinpoint the correct texture from the big texture.
You are swapping texture six times, BAD thing to do.
- Code: Select all
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[1]);
Another BIG performance hit. Instead, like I said, create one big texture, recalculate texture coordinates and call the bindTexture ONCE and render from there. Remember,
minimise state changes. Currently you are not doing it and it hits your performance.