OpenGL Are Polygons in OpenGL Divided?

This topic is 4238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

During a recent arguement with my friend, I could not prove to him that OpenGL divided polygons into triangles. We argued on this, because I believed if he calculated sprites out into triangles rather than quads, then passed them, he'd get a bit of a speed boost. This didn't pass with him, because I could not prove it. So, are polygons divided into triangles during rendering in OpenGL? What I'm mainly looking for it official sources, so I can show this guy how it works.

Share on other sites
All GeForce hardware and the latest generation of Radeon hardware can accept quads and polygons natively. That is, the driver does not decompose them into triangles. They do get chopped up into triangles by the hardware setup engine, but passing quads or polygons to the hardware can save you some vertex processing time. For example, rendering a bunch of particles as individual quads instead of pairs of triangles only requires the vertex program to be run 4 times as opposed to 6. (And the post-transform cache can't be used because we're not talking about indexed primitives.)

Why thank you :)

Share on other sites
Hmmm, alrighty. Good to know. Would they be same as, say, triangle strips? I mean handled the same way.

My point of view came from reading a couple articles on how software renderers work.

Share on other sites
Hey Eric, I didn't know you were still around these parts. Kick ass.

I have a question though. What do you get as results for wireframe mode with polygons and quads? I think the NV hardware can actually do wireframe natively, whereas ATI emulates it with slim triangles, so I'm curious what the results are on each.

Share on other sites
At the base level, the rasterizer works with triangles. You should be able to verify this because if you were to submit a polygon through the matrix stacks, the vertices would no longer be coplanar (due to precision problems) - and it shouldn't be able to be rendered. It should also accept non-convex polygons for this reason, but I haven't ever tried it to verify..

Share on other sites
I think you could probably show that a quad is divided into triangles by rendering a quad with coordinates like: (0,0,0) (1,0,0), (1,1,4), (0,1,0). Basically, make is so the quad doesn't lie in a plane, and you should see how it distorts.

There's two ways to make a rectangle from triangles:
--------|     /||    / ||   /  ||  /   || /    ||/     |--------

If the triangle is made like in the picture above, then using the coordinates above will lift up the lower right corner. This will result in the upper-left triangle being flat and the lower-right triangle streched upwards. You may have to play with which corner has a different z value, because the triangles could be divided across the other diagonal. But I think that would work.

Share on other sites
Quote:
 Original post by kanatoI think you could probably show that a quad is divided into triangles by rendering a quad with coordinates like: (0,0,0) (1,0,0), (1,1,4), (0,1,0). Basically, make is so the quad doesn't lie in a plane, and you should see how it distorts.There's two ways to make a rectangle from triangles:...If the triangle is made like in the picture above, then using the coordinates above will lift up the lower right corner. This will result in the upper-left triangle being flat and the lower-right triangle streched upwards. You may have to play with which corner has a different z value, because the triangles could be divided across the other diagonal. But I think that would work.

Doesn't really prove anything. The specification doesn't guarantee correct rendering unless the quad is planar (same with polygons too). So if you get the result you described, it could be because the result falls into the category of incorrect result instead of becuase it's split into two triangles.

Share on other sites
Quote:
 So, are polygons divided into triangles during rendering in OpenGL?

Before someone misunderstands the above answers, opengl documentation states, that the implementation is free to choose weither to decompose quads and bigger polygons into triangles or not, most of older hardware (i think nvidia 5xxx and older) do this in driver, but latest cards do it in hardware. you practically won't find any card capable of truly rendering native quads / multipolygons, altrough i think one console or some earlier espensive 3dfx chips were able to do it, it is not much use really and everybody rather decompose them to triangles at software or hardware level, to save room on the chip for different more important and modern features.

So you should rather send quads as quads and polygons as polygons, do not decompose them to triangles in your program by yourself, the driver or hardware will do it much faster than you ever can, and if in the future cards appear which will be able to natively render quads without decomposing them, your game / program will gain in visual detail.

Share on other sites
Quote:
 Original post by PromitHey Eric, I didn't know you were still around these parts. Kick ass.

I show up from time to time. :)

Quote:
 I have a question though. What do you get as results for wireframe mode with polygons and quads? I think the NV hardware can actually do wireframe natively, whereas ATI emulates it with slim triangles, so I'm curious what the results are on each.

I'm not exactly sure on this. It's true that Nvidia hardware handles wireframe rendering natively, but I don't know the details for ATI hardware. I seem to recall that the driver has to do some work and doesn't always get it right as far as the OpenGL spec is concerned.

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• Forum Statistics

• Total Topics
631785
• Total Posts
3002348
×