Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Count Polygon/Vertices in OpenGL scene ?

792 views
Skip to first unread message

J. Barnholt

unread,
Nov 14, 2002, 5:45:42 AM11/14/02
to
Hi there,

I was just wondering if there's an easy way to count the number
of vertices or polygons in an OpenGL scene for statistical/benchmark purposes ?

thanks a lot,
jan

Marc Boßerhoff

unread,
Nov 14, 2002, 5:57:00 AM11/14/02
to

If you draw your own objects, you already know the count of vertices and
polygons. if you don't know, you cannot draw them properly. Just init 2
variables before rendering and update them while rendering by adding the
vertex- & polygon-count for each object you draw.

Marc


J. Barnholt

unread,
Nov 14, 2002, 1:00:28 PM11/14/02
to
"Marc Bo erhoff" <ma...@nospam.gatetotheworld.de> wrote in message news:<aqvvhu$o1q$1...@f1node01.rhrz.uni-bonn.de>...

> If you draw your own objects, you already know the count of vertices and
> polygons. if you don't know, you cannot draw them properly. Just init 2
> variables before rendering and update them while rendering by adding the
> vertex- & polygon-count for each object you draw.
>
> Marc


Welcome to the marvelous world of OOP ;-)

The drawing involves a lot of classes in the application in question,
and I don't want to stuff some dummy counter-code in all involved
objects.

There must be a more elegant way to achieve this ?!
At least OpenGL must know what it draws..

-jan

zed

unread,
Nov 14, 2002, 3:18:03 PM11/14/02
to

i hope not (in the sense that opengl would count every vertice etc u
pass to it, what a waste of time, quake3 would perhaps run slower for
what?, knowing how many vertices are drawn)

anyways
*perhaps override glVertex3f (and vertex arrays etc) for a new (+
improved ;)) glVertex3f that also upadtes a counter
*if u just want to see how many vertices are finally onscreen. perhaps
draw the scene in white, + then set polygon mode to POINTS and draw the
scene in black read back pixels counting the number of black ones,
(watch out for zfighting etc)


--
lets hear it for billy bollux and his bouncing balls
http://uk.geocities.com/sloppyturds/kea/kea.html

Dmitry Shulga

unread,
Nov 14, 2002, 7:23:10 PM11/14/02
to
On 11/14/2002 2:18 PM, zed wrote:

> J. Barnholt wrote:
>
> > "Marc Bo erhoff" wrote in message
> > news:...


> >
> >
> >> If you draw your own objects, you already know the count of vertices and
> >> polygons. if you don't know, you cannot draw them properly. Just init 2
> >> variables before rendering and update them while rendering by adding the
> >> vertex- & polygon-count for each object you draw.
> >>
> >> Marc
> >>
> >
> >
> > Welcome to the marvelous world of OOP ;-)
> >
> > The drawing involves a lot of classes in the application in question,
> > and I don't want to stuff some dummy counter-code in all involved
> > objects.
> >
> > There must be a more elegant way to achieve this ?!
> > At least OpenGL must know what it draws..
>
>
> i hope not (in the sense that opengl would count every vertice etc u
> pass to it, what a waste of time, quake3 would perhaps run slower for
> what?, knowing how many vertices are drawn)
>
> anyways
> *perhaps override glVertex3f (and vertex arrays etc) for a new (+
> improved ;)) glVertex3f that also upadtes a counter
> *if u just want to see how many vertices are finally onscreen. perhaps
> draw the scene in white, + then set polygon mode to POINTS and draw the
> scene in black read back pixels counting the number of black ones,
> (watch out for zfighting etc)
>
>

I have not the exact solution for you. Just some ideas... Add a virtual function
that will return a number of vertices for each object. Or add a static counter
into the base class and increment it in each object derived from it while
drawing (or use global variable).

-d

Ralph Kern

unread,
Nov 15, 2002, 3:40:21 AM11/15/02
to
"J. Barnholt" schrieb:

use glRenderMode(GL_FEEDBACK) and render your scene to a feedback
buffer. (Surely not accelerated, but might work for statistical
purposes)

regards
Ralph

Steven

unread,
Nov 17, 2002, 2:45:37 AM11/17/02
to
(1) if you can modify the application easily, you can add counters there;
(2) if you have the OpenGL driver source code, you can add counters there;
(3) if you can find a tool that can trace the application's OpenGL calls,
and have the source code of the tool, you can add counters there;

(2) & (3) also work for third party applications.

Thanks,
Steven


"Dmitry Shulga" <sch...@erc.msstate.edu> wrote in message
news:3dd43...@nopics.sjc...

0 new messages