Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am using OpenGL ES 2.0 I have a bunch a quads to be drawn, would love to be able to have to pass only 4 vertices per quad as if I were using GL_QUADS, but basically I just want to know the best way of drawing a bunch of separate quads.

So far what I've found I could do: -GL_TRIANGLES(6 vertices per quad) -Degenerate GL_TRIANGLE_STRIP(6 vertices per quad)

Possibities I've found: -GL_TRIANGLE_STRIPS with a special index value that resets quad strip(this would mean 5 indexes per quad, but I dont think this is possible is OpenGL ES 2.0)

share|improve this question

4 Answers 4

up vote 21 down vote accepted

Just use index buffer and GL_TRIANGLES. In this case you need 4 vertices + 6 indices per quad (6 additional indices may sound large overhead but in reality it is not - once you have constructed your index buffer you don't have to touch it again). See this page for more information (search for glDrawElements)

Simple example code:

GLfloat vertices[] = {-1, -1, 0, // bottom left corner
                      -1,  1, 0, // top left corner
                       1,  1, 0, // top right corner
                       1, -1, 0}; // bottom right corner

GLubyte indices[] = {0,1,2, // first triangle (bottom left - top left - top right)
                     0,2,3}; // second triangle (bottom left - top right - bottom right)

glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);

Also, if you are drawing just one quad you need only 4 vertices to draw it with triangle strips (as shown in wikipedia) but I guess you already knew this.

share|improve this answer

Using index buffers isn't necessarily faster, as indicated in the Apple docs, "For best performance, your models should be submitted as a single unindexed triangle strip using glDrawArrays".

So, while a GL_TRIANGLE_STRIP will do it in 4 vertices without needing an index buffer, and you can use an index buffer, it's pretty lame to try to "save" repeating 2 vertices. For this reason, I'd suggest you draw 2 separate GL_TRIANGLES and repeat the 2 vertices on the diagonal.

share|improve this answer
Um, no. What that doc says is that your models be submitted as a single INDEXED triangle strip. And the very next sentence is, "To avoid specifying data for the same vertex multiple times in the vertex buffer, use a separate index buffer and draw the triangle strip using the glDrawElements function". Which is exactly what you decided was 'lame'. –  davidf2281 Mar 2 at 13:30

The big gain on desktop is to move the data into GL_STATIC_DRAW VBOs. Presumably this is true on iPhone's MBX GPU too.

share|improve this answer

Using GL_TRIANGLE_FAN for a quad uses 4 vertices, not 6.

share|improve this answer
Yep, but so does GL_TRIANGLE_STRIP, as other answers have already pointed out. –  Anko Jul 31 at 19:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.