Invisibilty

Is there a way to know witch object are not visible on the screen. For example, from the point of view, I have a box in front of 2 circle. What I need is a way to list those 2 circles, to know whats not visible. (by object, not pixels)

thx

You must sort your objets.

A sort for the Z axis and perhaps with the size of your objects.

I know I can use a well known algo to sort out wich object is visible or not but since the Z-buffer is already doing it, I was hoping for a built-in function who can give me a list of what is visible or not. If I build myself that function, I think I will loose a lot of speed since the program will do the same thing twice.

Thx

Well, if you have no more than, say, 255 objects, you can write a unique value to the stencil buffer when drawing each one, but I think you’d have to scan the entire stencil buffer manually to determine which objects had at least one visible pixel. I would expect this to be very slow, but it I think the setup would be something like so:

glClearStencil(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, objectNum, 0xff);
// Make sure not to use 0 as an objectNum
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

Make sure to ask for a stencil buffer in your gl setup code (PIXELFORMATDESCRIPTOR in Windows). After your render, you can use glReadPixels to read the stencil buffer, but like I said at the beginning, I’d expect this along with scanning the data read to be painfully slow.

–Travis Cobbs

Hi.

I was doing a lot of reserch and I think I will try to use the Selection Buffer. If you think it will not work, please let me know. I’m new to the OpenGl and I only have old books (Superbible 1996 and Programing guide Release 1). Anyway, I keep your solution in mind and if the selection buffer is a dead end, I will try your way.

Thank you for your help.

David