Jump to content
  • Advertisement
Sign in to follow this  
cosey

OpenGL Help, the number of pixels rendered

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!