Sign in to follow this  
wabbz111

Polygon count

Recommended Posts

wabbz111    162
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.

Share this post


Link to post
Share on other sites
wabbz111    162
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

Share this post


Link to post
Share on other sites
wabbz111    162
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

Share this post


Link to post
Share on other sites
solipcoder    300
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.

Share this post


Link to post
Share on other sites
SuperVGA    1132
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.

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

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

return sum;
}
[/code]
then
[code]
Node itreeroot(treeparams);
...
...
...
int total_polycount = itreeroot.polycount();
[/code] Edited by SuperVGA

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this