Triangles or Quads

Hi,

I’d like to know:

  1. If you need some quads which are not connectet, is it better to devide them and use triangles oder trianglestrips or just use quads?
  2. If these quads are connected, is it better to draw them as trianglestrips or quadstrips or maybe even as quads or triangles?

Generally speaking, when you can share vertices, you should do it. This increases performance pretty much everywhere, from cutting down on T&L (transform and lighting) as well as needing to push less data to define your geometry (vertex arrays, VBOs, or glVertex* calls ( <- yuck!)).

In the case of isolated quads, you’re in a bind because no matter what you’re going to need to represent that using 4 vertices.

if you have connected geometry however you can start taking some shortcuts. EX: You can use two vertices from the previous quad to define two vertices in your next (connected) quad. In this case you should try and make use of quad and/or triangle strips.

Yes, I already thought it would be better not to send vertices twice. But what I really wanted to know was whether it would be better to use triangles instead of quads when the number of vertices remains the nearly the same. :wink:
I heared somehow hardware could be sometimes more optimized for triangles and there could be some other problems with quads?

Maybe one of the “problems” you’ve heard is that a quad might not lie always on the same plane. Thus after some transformations it could end up not being convex and you might get bad results. With a triangle you’re guaranteed that its vertices are on the same plane. I don’t know of any speed problems that you mention.

This may be totally bogus, but I think I heard that even if you do send quads they are broken into triangles in the pipeline anyway. I think the whole quad thing is only to make our lives a bit easier.

Well, on ATI cards, quads definitely get changed into triangles. Interpolation acts differently, if you apply it on two triangles, than if you apply it on a quad. Therefore you can see on ATI cards, that they do that.

On nVidia cards i am not sure, i never noticed that there, so maybe they actually handle them like quads, but i don´t know.

It all depends on your app. If you have lots of connected quads/triangles (or even ONLY connected ones), than you should definitely optimize for that case.
However, if your geometry is in general quite “unconnected”, but in some cases it is connected, then don´t bother about it, simply use triangles for everything. An “optimisation” for those few cases would most certainly only hurt performance instead of increase it.

If you have lots of quads, you should use GL_QUADS, instead of triangles, because it reduces the amount of vertices/indices which get sent to the card, so it will save bandwidth but the card still has to calculate the same amount, so you won´t see a speed-difference, until your app gets bandwidth-limited.

Do you use VBOs / vertex-arrays? Or immediate mode? In the last case you will be limited by other factors anyway, so a real speedup would be to change to VBOs.

Jan.