Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: What is stencil buffer?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Nov 2001
    Location
    Malaysia
    Posts
    136

    What is stencil buffer?

    What is actually stencil buffer?
    Why use it and for what??
    Can someone show me example???

  2. #2
    Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    386

    Re: What is stencil buffer?

    The stencil test is a per pixel operation. When enabled it checks every pixel you draw using a specified stencil test. The stencil buffer used in the calculation of the stencil test. There are three things you need to know first
    glEnable(GL_STENCIL_TEST)
    simple enough, this enables (or you can disable) stencil testing
    the second is glStencilFunc(...) it takes three parameters. The first is a constant defined in gl.h that decides which operator is used as a stencil test, for example GL_EQUAL. The next parameter is the reference value, and the final parameter is the mask. When the stencil test is performed the program checks to see whether the value in the stencil buffer AND the mask value = (or whatever function you specify) the reference value AND the mask value. AND is the standerd boolean and. If the stencil test passes, the pixel is drawn, if not it is not.
    finally you need glStencilOp(...)
    this also has three parameters
    all three are constants in gl.h
    the first is what to do when the stencil test fails, so if you use GL_KEEP it will keep the current stencil value in the buffer when the stencil test fails
    the second parameter is the same thing except for when the depth test fails but the stencil test passes, the last is when both pass.
    I hope that makes sense, I am fairly sure its correct

  3. #3
    Junior Member Regular Contributor
    Join Date
    Nov 2001
    Location
    Malaysia
    Posts
    136

    Re: What is stencil buffer?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •