I’m calling the following method for each tile of a 64x64 terrain grid onscreen, and I’m finding that each method call takes the equivalent of about 10,000 clock cycles. Clearly, I must be doing something wrong.
protected void renderTo(Viewer v, GL rGL) {
currTex = type.texture;
currUV = UV[1][1];
currTex.bindTex(rGL);
rGL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, WHITE, 0);
rGL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, WHITE, 0);
rGL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, BLACK, 0);
rGL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, BLACK, 0);
rGL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 0);
rGL.glTexCoordPointer(2, GL.GL_FLOAT, 0, currUV);
rGL.glVertexPointer(3, GL.GL_FLOAT, 0, vertB);
rGL.glNormalPointer(GL.GL_FLOAT, 0, normB);
rGL.glDrawArrays(GL.GL_TRIANGLES, 0, 12);
}
(bindTex(), by the way, is no more than:
if(cached) bGL.glBindTexture(GL.GL_TEXTURE_2D, glID);
…so I’ve no real idea why on earth this should be so expensive.)
I’m using a shiny new 2.2 GHz Intel Core 2 Duo Macbook, with a GeForce 8600M GT. Each terrain tile is simply a set of 4 polys arranged around a centre of origin. What can I do to seriously optimise?