View Full Version : Polygon Counter

12-17-2002, 08: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.

12-17-2002, 10: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.


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

12-17-2002, 11:34 PM
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.

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

12-18-2002, 08: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.