PDA

View Full Version : Polygon Counter



dilectio
12-17-2002, 09:51 PM
Hi all,
I am using my own implementation of frustum culling. I wanna know if it is possible to query opengl to get number of polygons drawn in my scene.

JustHanging
12-17-2002, 11:08 PM
Before someone sends you to beginners forum...

You can't get the number of the triangles on the fly, but you can use the selection mode to get it.

Goes like tnis:
1. glSelectBuffer(size, buffer);
2. glRenderMode(GL_SELECT);
3. Draw your scene
4. numberOfTris = glRenderMode(GL_RENDER);

Please note, that you must have a selection buffer allocated, and it must be big enough to hold all possible triangles drawn (meaning size=3*maximum number of triangles), or else the second glRenderMode call will return -1. Actually, the buffer should be even a little larger, since clipping can create additional triangles.

-Ilkka

knackered
12-18-2002, 12:14 AM
My god, that's a reasonable use of GL selection! http://www.opengl.org/discussion_boards/ubb/smile.gif

pkaler
12-18-2002, 12:34 AM
Note that I haven't ran into a consumer level graphics card that hardware accelerates selection. So use sparingly. Setup a key or a command to toggle it on and off.

Humus
12-18-2002, 12:35 AM
Heh, ya. http://www.opengl.org/discussion_boards/ubb/smile.gif
I would suggest counting them yourself instead. Shouldn't be too hard.

pkaler
12-18-2002, 09:31 AM
It is easy to count on your own. Just add up your glVertex calls and the count you submit to glDrawElements. But you don't know how many vertices get culled.