I've been programming OpenGL for some time now but I'm quite new to OpenGL ES. One of issues I'm having is drawing primitives on the screen in an efficient maner.
I need to draw a number of equal line loops on the screen (with different translation) and noticed a huge performance drop with this code:
gl.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, this.vertices);
for (int j = 0; j < height; j++)
{
for (int i = 0; i < width; i++)
{
gl.glPushMatrix();
gl.glTranslatef(i, j, 0);
gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, 4);
gl.glPopMatrix();
}
}
I figure that the glDrawArrays is the bad guy here.
So the question is how can I draw a bunch of line loops efficiently? The glDrawArrays must be called for each primitive when using GL_LINE_LOOP so do I need to change the type to GL_LINES? This would impose a huge memory waste since the vertex array (in code above, holding 4 vertices) will then hold width * height * 8 vertices.
I'm programming for Android OpenGL ES 1.1.