Hallo guys
i have an highmap terrain generator and i would like to increase its preformance
my enigne in the beginning populate 3 bi-dimensional arrays
texture (x,y)
norma (x,y)
vertex (x,y)
inquerying the array by x and y i can get all the information of the vertex in the grid, becouse x and y is also the position of the vertex in the grid
in the beginnig i was using the GL_TRIANGLES to draw the grid and this is my algorithm
gl.glBegin(GL2.GL_TRIANGLES);
for (int x = 0; x < vertex.length-1; x++) {
for (int y = 0; y < vertex[0].length-1; y++) {
//triangle down
gl.glTexCoord2f(x/(float)(vertex.length-1), y/(float)(vertex[0].length-1));
gl.glNormal3d(normal[x][y].getX(),normal[x][y].getY(),normal[x][y].getZ());
gl.glVertex3d(vertex[x][y].getX(),vertex[x][y].getY(),vertex[x][y].getZ());
gl.glTexCoord2f((x+1)/(float)(vertex.length-1), y/(float)(vertex[0].length-1));
gl.glNormal3d(normal[x+1][y].getX(),normal[x+1][y].getY(),normal[x+1][y].getZ());
gl.glVertex3d(vertex[x+1][y].getX(),vertex[x+1][y].getY(),vertex[x+1][y].getZ());
gl.glTexCoord2f((x+1)/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));
gl.glNormal3d(normal[x+1][y+1].getX(),normal[x+1][y+1].getY(),normal[x+1][y+1].getZ());
gl.glVertex3d(vertex[x+1][y+1].getX(),vertex[x+1][y+1].getY(),vertex[x+1][y+1].getZ());
//triangle up
gl.glTexCoord2f(x/(float)(vertex.length-1), y/(float)(vertex[0].length-1));
gl.glNormal3d(normal[x][y].getX(),normal[x][y].getY(),normal[x][y].getZ());
gl.glVertex3d(vertex[x][y].getX(),vertex[x][y].getY(),vertex[x][y].getZ());
gl.glTexCoord2f((x+1)/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));
gl.glNormal3d(normal[x+1][y+1].getX(),normal[x+1][y+1].getY(),normal[x+1][y+1].getZ());
gl.glVertex3d(vertex[x+1][y+1].getX(),vertex[x+1][y+1].getY(),vertex[x+1][y+1].getZ());
gl.glTexCoord2f(x/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));
gl.glNormal3d(normal[x][y+1].getX(),normal[x][y+1].getY(),normal[x][y+1].getZ());
gl.glVertex3d(vertex[x][y+1].getX(),vertex[x][y+1].getY(),vertex[x][y+1].getZ());
}
}
gl.glEnd();
so to increase the performance i move all the data in a FloatBuffer but still i using the same algorithm to popoluate it
so means that i populate the FloatBuffer with GL_TRIANGLES
gl.glInterleavedArrays(GL_T2F_N3F_V3F, 0, modeldata);
gl.glDrawArrays(GL.GL_TRIANGLES, 0, modeldataElements);
the floatBuffer generate is very big, its size is
int length = maxX*maxY; //total vertex
modeldata = FloatBuffer.allocate(length*(6*(2 texture cordinate)+6*(3 normal cordinate)+6*(3 vertex cordinate)));
for a grid of 100 x 100 i have = 100 x 100 x 48 = 480.000 elements
actually in my games im using grid of 100 x 800 = 3.840.000 elements
the result in terms of performance is not increased,
and with my big surprise for big grid the fixed pipiline call are faster that the use of the glDrawArrays
so now I would like to use the GL_TRIANGLE_STRIP, because in this way i can reduce the size of the FloatBuffer and may be in this way i can increase the performace
that mean that i have to find a different algorithm to populate the FloatBuffer
is there someone of u that populate a grid with GL_TRIANGLE_STRIP and the data stored in 3 arrray like this one?
texture (x,y)
norma (x,y)
vertex (x,y)