Counting pixels

how do i count pixels? i am trying to calculate the projected area of a complex solid and it was recomended to count the number of pixels and compare it to an image of known size. any idea how to do this?

You could try occlusion queries. Take a look at ARB_occlusion_query.

If its 2d, look into glReadPixels for copying to mainboard ram where you can count the pixels.

you could use Shadow Volumes to render to the
stencil buffer.

with this technique you divide your solid into
polygons and render a shadow volume for each of
them to the stencil buffer. afterwards the stencil
buffer bits are 1 for each pixel, which is in the
shadow of the polygon.

i know it’s a bit complicated, but you could
even use it to project an arbitrary solid onto
an arbitrarily curved surface.