Help, the number of pixels rendered

Started by
4 comments, last by mikeman 18 years, 4 months ago
hi, guys, I met this problem. After I draw a model using opengl, I want to know, approximately, how many pixels are actually drawn on the viewport, or in other words the approximate area covered by the model on the viewport. Can anybody give me a clue how to do that? Thanks a lot.
Advertisement
It can't be done directly through OGL I'm affraid. Maybe if you implemented your own software rasterizer? ;) Anyway, what are you trying to do? Maybe we can help you find an alternative...
That's exactly what the GL_ARB_occlusion_query extension does, except it gives you the exact amount of pixels instead of an approximate amount.
But does it care about overdraw? If a complex model has parts in the back rendered first and then covered by parts in the front then using the number of drawn pixels will only give a rough idea of the filled area.
f@dzhttp://festini.device-zero.de
It would be quite slow, but you could use glReadPixels and manually count how many pixels are no longer black. This would get exactly the number of pixels, but any overdrawn pixels due to the depth of the model won't get caught since they are overdrawn by what is in front, or are culled due to being behind. That would depend on the order in which the model draws it's triangles/quads. But either way, if you know the resolution, use ReadPixels to get the actual pixel data and compare it to the color black.


Quote:Original post by Trienco
But does it care about overdraw? If a complex model has parts in the back rendered first and then covered by parts in the front then using the number of drawn pixels will only give a rough idea of the filled area.


It returns the number of samples that passed the tests(depth,stencil). If you want to measure only the ones that will end up being visible after all things are rendered, then simply perform a z-only pass first and then render the object you want to query, with depthfunc=GL_LEQUAL.

This topic is closed to new replies.

Advertisement