View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Polygon count

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

7 replies to this topic

### #1wabbz111  Members

Posted 19 November 2012 - 08:17 AM

Hi people,
I would like to know how i can get a polygon count for my 3D scene.
It will be purely for statistics so something simple will suffice.
My program is an l-system tree generator and i want to know
how many polygons are used to draw the various trees.
Any help is greatly appreciated.

### #2swiftcoder  Senior Moderators

Posted 19 November 2012 - 04:01 PM

You are sending each triangle to OpenGL - just count them in your own code.

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #3wabbz111  Members

Posted 20 November 2012 - 04:34 AM

Hi swiftcoder,
Could you please elaborate on the above statement
Do i use a counter? if so do i count the vertex buffer? or something else
Secondly i have seen info on glfeedback will it achieve the same thing?
THanks

### #4solipcoder  Members

Posted 20 November 2012 - 06:11 AM

How do you draw the tree? And don't you already know how many polygons there are in the tree when generating it?

### #5wabbz111  Members

Posted 20 November 2012 - 09:34 AM

I am using lines for trunk and branches, with leaves represented by an octahedron.
Since l-system generate the tree recusivelt i get mant branches and leaves.
I would like to know if there is a way to approximate how many are on the screen
.please look at the picture attached to see what i mean

### #6solipcoder  Members

Posted 20 November 2012 - 09:57 AM

I don't know how OpenGL handles lines, if we assume each line is 2 triangles:

Make a counter, numTriangles and set to 0 before rendering the tree (or generating it).

Every time you draw a line segment, increase numTriangles by 2. Every time you draw a leaf, increase numTriangles by 8.

### #7wabbz111  Members

Posted 20 November 2012 - 10:08 AM

Alright i will try it and let you know thanks.

### #8SuperVGA  Members

Posted 21 November 2012 - 04:27 AM

Or rather than counting while drawing (which is a nice and easy approach)
you could create a function in the node class that sums up the result of itself invoked on its children,
adds its own isolated polygon count, and returns the total value to the caller.

int polycount()
{
int sum = vertices.size() / 3;

foreach(Node n in children)
sum += n.polycount();

return sum;
}
then
Node itreeroot(treeparams);
...
...
...
int total_polycount = itreeroot.polycount();

Edited by SuperVGA, 21 November 2012 - 04:31 AM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.