• Advertisement
Sign in to follow this  

Difficult to understand stencil buffer

This topic is 4331 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all: I read the red book but I still found it is difficult to understand the stencil buffer. How does the stencil buffer draw pictures in a restrict area? And how do the two functions glStencilFunc(func, ref, mask); glStencilOp(fail, zfail, zpass); work? Why the mask value is always some strange value like 0xFFFFFFFF? What is that? Could anybody explain it in some details please? Thanks in advance!!!

Share this post


Link to post
Share on other sites
Advertisement
I still can't understand what the meaning of the reference value and mask value.
And the meaning things like 0xFFFF?

Share this post


Link to post
Share on other sites
Quote:
Original post by Asuralm
I still can't understand what the meaning of the reference value and mask value.
And the meaning things like 0xFFFF?
0xFFFFFFFF is a 32-bit hexadecimal number in which each bit is set to 1. mask is ANDed with both ref and the value in the stencil buffer for the current pixel. So if each bit of mask is 1, then it won't have any affect on ref or the current stencil value. For each bit in mask that is 0 the results of the AND with ref and the current stencil value will have that corresponding bit set to 0, no matter what it was originally in ref or the current stencil value. After that, those two results are tested against each other using the test function func. If that test fails, then the operation fail in glStencilOp is performed. If it passes but the depth test fails, then the operation zfail is performed. If the stencil test passes and depth test either passes or is disabled (or there is no depth buffer) then the operation zpass is performed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement