Original Post
I'm trying to speed up my program by rendering my 2D vertices grid using vertex arrays. The problem is I saved the vertices in a 2-dimensional array (vertices[x][z]). x and z have the same limit, which is the map_length (length in one direction). Normally my drawing function (which draws the array in quads) draws the whole array somewhat like this: glBegin(GL_QUADS) for (int z = 0; z < map_length - 1; z++) { for (int x = 0; x < map_length - 1; x++) { glVertex3f(vertices[x][z].x, vertices[x][z].y, vertices[x][z].z); glVertex3f(vertices[x+1][z].x, vertices[x+1][z].y, vertices[x+1][z].z); glVertex3f(vertices[x+1][z+1].x, vertices[x+1][z+1].y, vertices[x+1][z+1].z); glVertex3f(vertices[x][z+1].x, vertices[x][z+1].y, vertices[x][z+1].z); } } glEnd(); Unfortunately, vertex array functions do not use 2-dimensional arrays, and even if I could use it, the points would only be used once and I would not get proper rendering (each vertex is used 4 times, except at edges). I thought about making a one-dimensional array out of the vertices, but this would use 4 times as much memory, which seems a bit steep. I also thought of making the one-dimensional vertex array an array of pointers, all pointing to the right place in the two-dimensional array (I'd very much like to keep usign the two-dimensional array, since it saves me quite a lot of code in functions that edit the grid). Well, the above method doesn't work for me. I suspect OpenGL Vertex Arrays don't like arrays of pointers. Who knows a/the solution? I'd be very grateful for any advice! Edit: I am not sure what is going wrong. I am quite unsure about stride and stuff, because vertices is a class with more than just an x, y and z. It's a full class with functions and these members: float x, y, z; float xn, yn, zn; (normal) float* u, *v; (pointers so I have texture coordinates for all the different textures (multitexturing) [Edited by - Subotron on September 22, 2006 12:51:48 PM]