Wow, thanks to everyone for his response! You guys are awesome, never thought I would get so much help here
(1) This is the code of drawing only one tetris block?
In this case you should batch your draw calls, e.g. collecting all the static blocks into one buffer and render it once.
(2) Or do you render the whole game screen into a texture and draw it onto 2 triangles?
Texture creation is a slow operation and should not be called in every frame.
(3) I don't understand your code.
What do you mean with one "buffer"? One vertex buffer object?
Have you tried not doing the glEnable/glEnableClientState/glDisableClientState/glDisable for every primitive? I see no reason why you should have to keep doing this.
Yes, but that didn't help.
For your particular type of graphics you can probably get away with using a single texture and color modulation to draw the blocks in one batch call.
I'm already using only one texture for a block, coloring it with glColor3ub.
You could also try using quads instead of triangle strips, but I have no idea which one performs better.
GL_QUADS is not defined in my GL ES headers that's why I'm using GL_TRIANGLE_FAN.
true, use fixed point - everywhere.
Although that would improve the performance a bit, I am too lazy to change all my code. Furthermore I would need to set up some kind of custom type, so that I can still compile my game for normal OpenGL.
are they really your bottleneck? try to do some timings on different sub-parts of your code and see what part takes that long. i can't really imagine that it's the draw code all alone.
I also tried to comment out (can you say so in English?) some code about the game logic like checking for full lines. Even changing the Wiz clock speed doesn't change the FPS that much, so I really think the drawing is the bottleneck.
Drawing the whole scene...
1 draw tex for the background + labels (no prior clearing - this overdraws everything)
<=5 times draw tex for score
<=2 times draw tex for level
<=3 times draw tex for lines
<=4 times draw tex for time
1 draw tex for preview
1 VBO for the blocks on the floor
1 whatever for the midair piece (w/o smooth rotation you could also use draw tex there)
~16 times drawtex and ~2 VBOs. Only one texture which is bound outside the loop. Should easily run at 60fps, I guess.
Unfortunately it's to complicated to change my code so that this works. For example I'm not directly using OpenGL but a custom library written by myself. I could change it's API to allow more optimization but I don't want to do that.
The first thing i would do is disable the textures in your code and try rendering all your elements with vertex colors or just flat shaded.
I tried that, but it didn't help.
Another thing worth checking (i cant remember if this applies to opengl it certainly does for SDL) is that colour depth of your textures match your screens colour depth (The one you initialised openGL with).
It's true - I have initialised OpenGL ES with 16 bit, while I am using 24 bit colors. But setting EGL_BUFFER_SIZE to anything else than 16 results in weird graphical glitches. Has anyone managed yet to set up 24 bit OpenGL ES display on the Wiz?
It looks like to me that your using a VBO for the texture information, but not for the vertices. I'd expect your drawing code to do something more similar to:
glVertexPointer(2, GL_FIXED, 4 * sizeof(GLfixed), 0);
glTexCoordPointer(2, GL_FIXED, 4 * sizeof(GLfixed), (GLvoid *)(2 * sizeof(GLfixed)));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
Note that this example used fixed point, not floating point, but you get the idea.
Yeah, you're right thanks! I was using vertex arrays, but not VBOs. I thought since the Wiz has no dedicated video memory the speed would be the same. How I was wrong: Now it's about 40 % faster!
As some of you already suggested: I also changed, that glBindBuffer, glVertexPointer and glTexturePointer are only called before drawing ALL blocks and not before drawing every block.
It's still not fast enough though, but definitely playable (assuming you don't suck at Tetris). You can download it here: http://watteimdocht.de/jan-nik/jntetri_wiz_beta1.zip
One thing that also isn't right: After quiting my application you can still see 2/3 of the last frame (hard to describe in English, sry). And my game cannot be started a second time. I heard this is a bug of libopengles_lite.so, is it?