Quad with multiple vertices

Ok, so when you make a quad it has four vertices right, top left, top right, bottom left, bottom right, to make the polygon. Well, I’m making a terrain editing program, like what’s used in Empire Earth, so it’s all flat and u can raise it and stuff. What I did was just have a file that reads in these vertices and makes the map right, so i have four vertices for each square, which also causes a lot of redundancy, because i have the points like…
. .
. .
for one square, then the next one has to be right next to it, so it has to share the vertex point value, but i just want it to share the entire vertex to save points, ya know, so instead of…
. … .
. … .
(the ones side by side would be the same value) I want…
. . .
. . .
basically just one quad with many vertices, so if I raise one i don’t have to raise the matching one of the other block. If that’s not possible, what would be the most efficient way of doing this? Cuase I did it alright, but I know it’s not very effective the way I did it. Thanks all.


Take a look at QUAD_STRIP, it might be what you are looking for.


And if you can use QUAD_STRIP, you can use TRIANGLE_STRIP and it might be slightly faster.

– Zeno

I think you are confusing database management with actual rendering. It is perfectly alright to have only one copy of the vertex and render it twice. Although the rendering might be less efficient, but you won’t need to duplicate any change to the database.


float a[][] = {
{0.0, 5.0, -5.0 },
{1.0, 3.0, 2.0 },
{4.0, -2.0, 1.0 },
{3.0, 1.0, 1.0 }

// As you can see, there is only 4 vertices. but you can render it as such:

glVertex3fv( a[0]);
glVertex3fv( a[1]);
glVertex3fv( a[2]);

glVertex3fv( a[1]);
glVertex3fv( a[2]);
glVertex3fv( a[3]);

So if you update let’s say a[2], both triangles will be updated.

p.s. in the above case it’s better to use TRIANGLE_STRIP, but if you have a large db with discontinous surfaces, you might want to fall back on GL_TRIANGLES,

One problem you may run into by using quads will the possibility of having your vertices non-planar, which could have unknown results.

Example… you lift 1 vertex of a square, the other vertices stay in place… in effect, you’ve “bent” the quad so that it is no longer planar.

If you use triangles instead, you will always know your vertices are planar.

Yeah I’d also suggest you work with triangles.If you use Quads like Deissum said you have to restrict the quads to being planar which wont give you a good looking terrain.

so you could use the same arrangement and let your quads be non planar and render them as triangles.

Create a list of vertices and then create a list of triangles that contain these vertices. Like this:

1 - 0,0,0
2 - 50,0,0
3 - 0,50,0
4 - 50,50,0
5 - 50,50,50
6 - etc.

1 - 1,2,3
2 - 2,3,6
3 - 3,6,5
4 - etc.

Notice that the triangles share the same vertices, so when you change the coordinates of a specific point, all triangles connected will adjust.