Well it’s quite a low spec gcard, but I was down to 7fps, back to 20fps now after the changes, but I think I’m CPU bound for some reason.
Thanks for the link.
This is the code for drawing the solid bricks: but I call the same code but use GL_LINES
gl.glBindTexture(GL.GL_TEXTURE_2D, textureStud);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
loop 5600 times
float tx = drawQx + (QUEST_TILE_LENGTH * x);
float ty = drawQy + drawY;
int height = mapData[qx][qy].height[x][y];
float tz = ClientConstants.STD_BRICK_HEIGHT * height;
gl.glColor3fv(questColorTable[height+ -CorkConstants.MIN_MAP_HEIGHT], 0); //adjust height to be zero based.
// solid brick
gl.glTranslatef(tx, ty, tz);
gl.glBegin(GL.GL_QUADS);
drawQuestTile(gl, false);
gl.glEnd();
gl.glTranslatef(-tx, -ty, -tz);
And this is for a single brick
private static final void drawQuestTile(final GL gl, final boolean wireframe) {
float BASE = 0.0f; // base height...
float HEIGHT = STD_BRICK_HEIGHT;
float WIDTH = 4;
float LENGTH = 4;
float[] normal;
// front
normal = Utils.calcNormal(new float[] { 0, 0, BASE }, new float[] { LENGTH, 0, BASE }, new float[] { LENGTH, 0, HEIGHT });
gl.glNormal3fv(normal, 0);
gl.glVertex3f(0, 0, BASE);
gl.glVertex3f(LENGTH, 0, BASE);
gl.glVertex3f(LENGTH, 0, HEIGHT);
gl.glVertex3f(0, 0, HEIGHT);
// back
normal = Utils.calcNormal(new float[] { LENGTH, WIDTH, BASE }, new float[] { 0, WIDTH, BASE }, new float[] { 0, WIDTH, HEIGHT });
gl.glNormal3fv(normal, 0);
gl.glVertex3f(LENGTH, WIDTH, BASE);
gl.glVertex3f(0, WIDTH, BASE);
gl.glVertex3f(0, WIDTH, HEIGHT);
gl.glVertex3f(LENGTH, WIDTH, HEIGHT);
// w end
normal = Utils.calcNormal(new float[] { 0, WIDTH, BASE }, new float[] { 0, 0, BASE }, new float[] { 0, 0, HEIGHT });
gl.glNormal3fv(normal, 0);
gl.glVertex3f(0, WIDTH, BASE);
gl.glVertex3f(0, 0, BASE);
gl.glVertex3f(0, 0, HEIGHT);
gl.glVertex3f(0, WIDTH, HEIGHT);
// e end
normal = Utils.calcNormal(new float[] { LENGTH, 0, BASE }, new float[] { LENGTH, WIDTH, BASE }, new float[] { LENGTH, WIDTH, HEIGHT });
gl.glNormal3fv(normal, 0);
gl.glVertex3f(LENGTH, 0, BASE);
gl.glVertex3f(LENGTH, WIDTH, BASE);
gl.glVertex3f(LENGTH, WIDTH, HEIGHT);
gl.glVertex3f(LENGTH, 0, HEIGHT);
// bottom
normal = Utils.calcNormal(new float[] { 0, 0, 0 }, new float[] { LENGTH, 0, 0 }, new float[] { LENGTH, WIDTH, 0 });
gl.glNormal3fv(normal, 0);
gl.glVertex3f(0, 0, BASE);
gl.glVertex3f(LENGTH, 0, BASE);
gl.glVertex3f(LENGTH, WIDTH, BASE);
gl.glVertex3f(0, WIDTH, BASE);
// top
normal = Utils.calcNormal(new float[] { 0, 0, HEIGHT }, new float[] { LENGTH, 0, HEIGHT }, new float[] { LENGTH, WIDTH, HEIGHT });
gl.glNormal3fv(normal, 0);
if(!wireframe)gl.glTexCoord2f(0.0f, 0.0f);
gl.glVertex3f(0, 0, HEIGHT);
if(!wireframe)gl.glTexCoord2f(QUEST_TILE_STUD_COUNT, 0.0f);
gl.glVertex3f(LENGTH, 0, HEIGHT);
if(!wireframe)gl.glTexCoord2f(QUEST_TILE_STUD_COUNT, QUEST_TILE_STUD_COUNT);
gl.glVertex3f(LENGTH, WIDTH, HEIGHT);
if(!wireframe)gl.glTexCoord2f(0.0f, QUEST_TILE_STUD_COUNT);
gl.glVertex3f(0, WIDTH, HEIGHT);
}