If you want to get a triangle strip for witch you have every vertex in an array, you should make an array of the vertices first.
The standard rectangle shaped mesh generation looks like this:(its in c++, but use it as pseudocode)
for(int x=0; x<sizex; x+=stepsize)
{
for(int y=0; y<sizey; y+=stepsize)
{
vertexarray.push_back(vec3(x,y,z)); //for a plane set z to any const.
}
}
then you can make an index array for this:
for(int x=0; x<sizex-1; x+=stepsize)
{
for(int y=0; y<sizey-1; y+=stepsize)
{
indexarray.push_back(y*sizex+x);
indexarray.push_back(y*sizex+x+1);
indexarray.push_back((y+1)*sizex+x); //first triangle in the strip
indexarray.push_back((y+1)*sizex+x);
indexarray.push_back(y*sizex+x+1);
indexarray.push_back((y+1)*sizex+x+1); //second triangle
}
}
then the size of the index array is
GLint count = 6(sizex-1)(sizey-1);
and in the render call you can use VAOs VBOs, or in FFP:
//the following is your code
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
for (int i = 0; i< count i++)
{
GL11.glVertex3f(vertexarray[indexarray[i]].x, vertexarray[indexarray[i]].y, vertexarray[indexarray[i]].z);
}
GL11.glEnd();
for the surface normals you can easily get the triangle points, iterating through the vertices, get their neighbours and calculating the cross products not that hard at all. You can easily extract the triangles from the index array too.
int i = 0, t = 0;
for(int x=0; x<sizex-1; x+=stepsize)
{
for(int y=0; y<sizey-1; y+=stepsize)
{
indexarray.push_back(y*sizex+x);
indexarray.push_back(y*sizex+x+1);
indexarray.push_back((y+1)*sizex+x); //first triangle in the strip
indexarray.push_back((y+1)*sizex+x);
indexarray.push_back(y*sizex+x+1);
indexarray.push_back((y+1)*sizex+x+1); //second triangle
triangles[t].vertex1.xyz = vertexarray[indexarray[i]].xyz;
triangles[t].vertex2.xyz = vertexarray[indexarray[i+1]].xyz;
triangles[t].vertex3.xyz = vertexarray[indexarray[i+2]].xyz;
triangles[t+1].vertex1.xyz = vertexarray[indexarray[i+3]].xyz;
triangles[t+1].vertex2.xyz = vertexarray[indexarray[i+4]].xyz;
triangles[t+1].vertex3.xyz = vertexarray[indexarray[i+5]].xyz;
t+=2; //you made 2 triangles
i+=6; //passed over 6 indeces that make up the 2 triangles
}
}
EDIT: the triangle structure:
struct TRIANGLE{
vec3 vertex1, vertex2,... //or vertex[3]; to declare it as an array too
};
struct vec3{
int x, y, z;
//float f_x,f_y,f_z;
vec3(int X; int Y; in Z):x(X),y(Y),z(Z){};
~vec3(){};
};
the vertices or indexes array could be list or any container. I prefer vector in C++.
The size of the triangle array is:
TRIANGLE* triangles = new TRIANGLES[count/3];
//3 vertices for a triangle, same as (sizex-1)*(sizey-1)*2 for 2
//triangles for every quad that makes up the mesh, and it has (sizex-1)(sizey-1) quads