View Full Version : presented/projected area
06-10-2005, 03:40 AM
is it possible to use openGL to calculate the presented/projeced area of 3d object?
06-10-2005, 04:05 AM
Depending exactly what you want to do, you could probably get a close estimate by using occlusion queries, which tells you, basically, how many pixels were actually drawn.
So, you draw your object, in the orientation you desire then draw a rectangle of known area that is guaranteed to be behind the object (because you arrange things this way), then the known area minus the drawn area is the area of the object.
If you mean the amount of screenspace taken by an object:
1. clear framebuffer.
2. set up projection. If you want sideviews, use an ortho projection.
3. render object without flat shading in a different color from the clearcolor.
4. use glReadPixels to read back the picture.
5. loop through the pixels, count the ones that are not the same as the background color.
There may be better performing methods using shaders or maybe occlusion queries, but this would be the simplest.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.