for(int y = 0; y < YDIM; y++) {
for(int x = 0; x < XDIM; x++) {
indices[i++] = y * (XDIM+1) + x;
indices[i++] = y * (XDIM+1) + x + 1;
indices[i++] = (y + 1) * (XDIM+1) + x+1;
indices[i++] = y * (XDIM+1) + x;
indices[i++] = (y + 1) * (XDIM+1) + x+1;
indices[i++] = (y + 1) * (XDIM+1) + x;
indexCount += 6;
}
}
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, 6*sizeof(GLfloat), vertices);
glNormalPointer(GL_FLOAT, 6*sizeof(GLfloat), &(vertices[0].nx));
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, indices);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY)