Results 1 to 5 of 5

Thread: Invisibilty

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2002
    Posts
    3

    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

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Re: Invisibilty

    You must sort your objets.

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

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2002
    Posts
    3

    Re: Invisibilty

    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

  4. #4
    Member Contributor
    Join Date
    Feb 2002
    Posts
    58

    Re: Invisibilty

    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

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2002
    Posts
    3

    Re: Invisibilty

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean