waht's the "Stencil Test" Compare

void StencilFunc( enum func, int ref, uint mask )
The stencil test conditionally discards a fragment based on the outcome of a comparison
between the value in the stencil buffer at location (xw, yw) and a referencevalue.
So i don’t understand what’s the value in the stencil buffer stand for. the value of RGBA?or something else?
for depth test, it is clear that the value of Z coordinate is compared.

Wikipedia is your friend:
“A stencil buffer is an EXTRA BUFFER, in addition to the color buffer (pixel buffer) and depth buffer (z-buffering) …”
=> http://en.wikipedia.org/wiki/Stencil_buffer
Stencil buffer is a integer buffer, and it’s use for binary test like: equal, less, more, notequal, etc …
“the stencil buffer is used to limit the area of rendering (stenciling)”


No, the stencil buffer is another data buffer, similar to color (rgba) and depth, but separate.
Typically 8 bits. Can be used to draw masks for example. Mandatory to use stencil shadows (less useful now).

Maybe this page can help you understand better the stencil buffer and its possibilities :

EDIT: yoyonel was faster