area calculation

Hello, :confused:
Please help me.
I draw a complicated figure such as a map by gluTessBeginPolygon in the XY plane.
I want to get the area of the sub region on the map.
So I copied the image of the sub region into main memory by glutReadPixels and I counted the pixel value.
By this method, I could count the area of the sub region of the map.
However, I want to get a lot of other sub region’s area of the map.
Is there a faster method to get the area of the drawing image?

http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt

Hello Hlz,
Thank you very much.
By your suggestion, I could get the are of image very faster by ARB_occlusion_query method.
My program became ten times faster.

I have an additional question.
Can I use ARB_occlusion_query with off-screen window?
I found a good sample of ARB_occlusion_query,

http://www.codesampler.com/source/ogl_occlusion_query_arb.zip

and I tried to make window invisible but I could not do that.

Please give me hint.

You need to render to an offscreen rendering context not an occluded or invisible window.

The problem is that occluded (or invisible) areas of the render buffer produce undefined values when rendered to.

Use a PBuffer (or better yet an FBO if your graphics card supports it). You should then have no problem using occlusion queries.

Hello,
I could use ARB_occlusion_query with PBuffer.
This is what I want to do!
Thank you very much.