PDA

View Full Version : Polygon Performance



redarrow
05-12-2005, 06:04 AM
Hi all,

Is there any performance decrease to draw only using
polygons? From a programming point of view it's a lot easier to just use polys regardless of how many points I have.

Let's say I load a model from a file, it's got a lot of poly's triangle's and quads,
If a particular face has 4 vertices is it going to make a negative impact on performance to render it as a poly?

I don't notice any performance loss in tests I ran,
but I'm wondering if it might show up on really large models?

Thanks!

Relic
05-12-2005, 07:30 AM
The problem with GL_POLYGON is, it is not an independent primitive and needs one glBegin-glEnd or one glDrawArrays or one glDrawElements, etc. call per polygon!
If your model has a lot of triangles and quads it's MUCH faster to batch them into one primitve type GL_TRIANGLES or GL_QUADS and draw them in one single array call.

redarrow
05-12-2005, 07:56 AM
Thanks for the info,

Does it make any difference that I'm using gl lists?

In my tests I did glBegin.. glEnd() for each triangle, quad or poly .. which is maybe why I didn't notice any difference.

Relic
05-13-2005, 01:41 AM
Does it make any difference that I'm using gl lists? It's generally faster than immediate mode, but a polygon needs to stay a polygon because it has a different flat shading behaviour than any other primitive (GL_POLYGON uses the first vertex color, all other use the last vertex color of each subprimitive.)
Immediate mode with one primitive per begin-end is about the slowest way to send geometry to OpenGL!
Display lists are server state and the OpenGL implementation can optimize the data as it likes, but sending good data is your responsibility.
It might even be beneficial to never use polygons and split everthing into batches(!) of triangles and quads. Bench that.

redarrow
05-13-2005, 01:57 AM
OK, thanks for all the info!