View Full Version : Triangles or quads

Let's say i'd like to read my 3d level to array of structures. I can to this in many ways. I can save it as triangles or as quads. Which should I choose? Is there any difference, meaby one of them work faster?

Thanks in advance!

Structural

01-02-2003, 10:39 PM

Basically a quad is rendered as two triangles.

I prefer triangles because:

1) there is no possible way of making a triangle concave

2) it gives one more freedom in modelling

I don't know if there is any significant performance gain in using either of them, but I switched to triangles just for the sake of my models.

I think quads are also easy to use. Although models are made form triangles. Meaby there isn't any bigger difference?

Thanks

Deiussum

01-03-2003, 06:31 AM

If you use quads, you also need to make sure that all the vertices are coplanar, or you will end up with undefined results. With triangles, you don't have to worry about this. I tend to prefer using triangle strips and fans where possible.

atimes

01-03-2003, 07:51 AM

Go for the triangles. If you use glBegin(GL_QUADS) OpenGL will internally convert all quads to triangles anyway (since a square is just 2 triangles) if you do it before hand and use glBegin(GL_TRIANGLES) you save OpenGL the trouble.

Orzech

01-04-2003, 12:46 AM

Thanks you all. I'll use triangles them.

SThomas

01-04-2003, 02:54 AM

Originally posted by Deiussum:

If you use quads, you also need to make sure that all the vertices are coplanar, or you will end up with undefined results.

that's not true, is it? i use non-coplanar quads with no problem, and i can't find anything in the spec that says that behavior will be undefined if the quads aren't coplanar. i don't see why they'd have that restriction.

Miguel_dup1

01-04-2003, 04:19 PM

Well, I can see that if you have a quad, you only give four vertices. BUT, with triangles you will need six to get the same quad. So, there is a bit of a difference in performance due to less glVertex calls.

I wrote a terrain engine where you can chose to use GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP at runtime and of course the triangle strip had the best performance, but quads gave a bit better performance than the triangles did.

You will need to use triangles and quads in different situations, hence the option of using either one exist!!! http://www.opengl.org/discussion_boards/ubb/wink.gif

Regards,

Miguel Castillo.

Deiussum

01-05-2003, 06:02 PM

So far as I can see there is nothing in the OpenGL spec that says a quad will be converted to triangles. Current drivers are likely to do that for performance reasons, however.

Now consider for a moment a quad that has 4 non-coplanar vertices. There is no way to properly draw a single planar polygon that will pass through all 4 points. So assume that the implementation does convert quads to triangles. How does it decide how to split it? Top left to bottom right, top right to bottom left? Since the OpenGL spec doesn't say anything about splitting quads into triangles, it doesn't define what should be done if a quad is not coplanar.

One implementation may decide to split it into triangles one way, another may decide to split it the other way. Thus the behavior is left up to the implementation, and therefore undefined.

John Jenkins

01-06-2003, 05:58 AM

The main difference is that triangles have three sides and quads have four. Hope this helps.

DaSheriff

01-06-2003, 09:04 AM

Originally posted by Barbarian:

Let's say i'd like to read my 3d level to array of structures. I can to this in many ways. I can save it as triangles or as quads. Which should I choose? Is there any difference, meaby one of them work faster?

Thanks in advance!

Besides the fact that triangles cannot be concave (one less thing to worry about), the only other difference between quads and triangles is simply..the amount of vertices needed to produce a primitive.

Specifically a triangle strip. One you define the initial triangle w/3 vertices, each additional vertex produces a triangle primitive.

Which means, constructing 3d objects using triangle strips requires far less vertices than using quads. The less vertices your program uses to construct your objects, the better the performance.

SThomas

01-06-2003, 05:38 PM

Originally posted by Deiussum:

Now consider for a moment a quad that has 4 non-coplanar vertices. There is no way to properly draw a single planar polygon that will pass through all 4 points.

yeah, i guess it comes down to the definition of a quadrilateral, which is a 4 sided planar figure. this really kills the usefulness of quads though. all of the cards i've ever tested on just take quads with non-coplanar vertices and break them up into triangles anyway, so it'd be nice if they standardized that behavior. if the spec said something like, "if the 4 vertices making up the quad aren't coplanar, then the quad will be split into two triangles along the diagonal connecting the upper left vertex to the lower right vertex," that'd help a lot.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.