files/en-us/web/api/webglrenderingcontext/stencilop/index.md
{{APIRef("WebGL")}}{{AvailableInWorkers}}
The WebGLRenderingContext.stencilOp() method of the WebGL API sets both the front and back-facing
stencil test actions.
stencilOp(fail, zfail, zpass)
fail
gl.KEEP.zfail
gl.KEEP.zpass
gl.KEEP.None ({{jsxref("undefined")}}).
gl.KEEP
gl.ZERO
gl.REPLACE
gl.INCR
gl.INCR_WRAP
gl.DECR
gl.DECR_WRAP
gl.INVERT
The stencil testing is disabled by default. To enable or disable stencil testing, use
the {{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
gl.STENCIL_TEST.
gl.enable(gl.STENCIL_TEST);
gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT);
To get the current information about stencil and depth pass or fail, query the following constants with {{domxref("WebGLRenderingContext.getParameter", "getParameter()")}}.
gl.getParameter(gl.STENCIL_FAIL);
gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS);
gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL);
gl.getParameter(gl.STENCIL_BACK_FAIL);
gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS);
gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL);
gl.getParameter(gl.STENCIL_BITS);
{{Specifications}}
{{Compat}}