Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


The glClearStencil function specifies the clear value for the stencil buffer.

void glClearStencil(
  GLint s


The index used when the stencil buffer is cleared. The default value is zero.


The glClearStencil function specifies the index used by glClear to clear the stencil buffer. The s parameter is masked with 2m 1, where m is the number of bits in the stencil buffer.

The following functions retrieve information related to the glClearStencil function:

glGet with argument GL_STENCIL_CLEAR_VALUE

glGet with argument GL_STENCIL_BITS

Error Codes

The following is the error code generated and its condition.

Error code Condition
GL_INVALID_OPERATION glClearStencil was called between a call to glBegin and the corresponding call to glEnd.


  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Gl.h.
  Library: Use Opengl32.lib.

See Also

glBegin, glClear, glEnd, glGet


Community Additions

© 2015 Microsoft