Question about glDrawElements vs glDrawArrays

Hi.
I am drawing lots of rectangles in a 2D application. For each rectangle I am drawing 2 triangles.
Right now I am using a VBO with an Array-Buffer and an Element-Array-Buffer in combination with glDrawElements.
However, I dont use many shared vertices. Each rectangle has 4 vertices and 6 indices, so only 2 vertices are shared per 2 triangles.
So I was thinking that maybe using glDrawArrays with GL_QUADS instead of GL_TRIANGLES would be a better idea.

My benchmarks have shown absolutely no difference in terms of performance with either of both. However, I am not quite sure how this would go on other kinds of hardware, especially laptops with limited graphics capabilities.

Thank you very very much for the help. I really appreciate it.

[QUOTE=Cornix;1256070]Hi.
I am drawing lots of rectangles in a 2D application. … So I was thinking that maybe using glDrawArrays with GL_QUADS instead of GL_TRIANGLES would be a better idea.[/QUOTE]

Are these quads part of a connected grid, or are they isolated quads?

If connected, then properly optimized triangles would win. If they are isolated quads, there’s not much to be gained either way.

My benchmarks have shown absolutely no difference in terms of performance with either of both.

If you are bottlenecked on something else, that would be expected and would invalidate the conclusion you’re trying to make.

The quads are not connected at all. They are just batched in one big array-buffer.

I am just not sure if it would be a problem to use glDrawArrays with GL_QUADS instead of drawing triangles. Because with glDrawElements I can reuse 2 vertices for each quad making it 4 vertices for 2 triangles instead of 6 vertices. With glDrawArrays this wouldnt work that way. Since I dont want to change the code with which I upload the vertex-data I would use glDrawArrays with GL_QUADS instead.

The main issue with GL_QUADS is that it’s deprecated, i.e. it doesn’t exist in 3.x core profile or OpenGL ES. In practice, each quad will be split into two triangles, but it’s undefined as to how (i.e. which diagonal is used for the split). Although this probably doesn’t matter for 2D rectangles, this means that the result of rendering quads is undefined unless the quads are planar and the mapping of attribute values to the plane is affine.