StencilGL 1.0

glClearStencil

Sets the value glClear writes into the stencil buffer.

Signature

void glClearStencil(GLint s);

How it works

Like glClearColor for color, this only stores the value; glClear(GL_STENCIL_BUFFER_BIT) writes it into every pixel. The default is 0, which is what almost every technique expects.

Parameters

sGLint

The clear value, 0 by default (only the low 8 bits are kept with an 8-bit buffer).

Tips & pitfalls

  • The clear goes through glStencilMask: with mask 0x00 the stencil buffer is not cleared at all.

Example

example.cpp
1glClearStencil(0);
2glStencilMask(0xFF);
3glClear(GL_STENCIL_BUFFER_BIT);
Official Khronos documentation