The WebGLRenderingContext.stencilOpSeparate() method of the WebGL API sets the front and/or back-facing stencil test actions.
void gl.stencilOpSeparate(face, fail, zfail, zpass);
The fail, zfail and zpass parameters accept all constants listed below.
GLenum specifying whether the front and/or back stencil state is updated. The possible values are: gl.FRONTgl.BACKgl.FRONT_AND_BACKfailGLenum specifying the function to use when the stencil test fails. The default value is gl.KEEP.zfailGLenum specifying the function to use when the stencil test passes, but the depth test fails. The default value is gl.KEEP.zpassGLenum specifying the function to use when both the stencil test and the depth test pass, or when the stencil test passes and there is no depth buffer or depth testing is disabled. The default value is gl.KEEP.None.
gl.KEEPgl.ZEROgl.REPLACEWebGLRenderingContext.stencilFunc().gl.INCRgl.INCR_WRAPgl.DECRgl.DECR_WRAPgl.INVERTThe stencil testing is disabled by default. To enable or disable stencil testing, use the enable() and disable() methods with the argument gl.STENCIL_TEST.
gl.enable(gl.STENCIL_TEST); gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT);
To get the current information about stencil and depth pass or fail, query the following constants with 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);
| Specification | Status | Comment |
|---|---|---|
| WebGL 1.0 The definition of 'stencilOpSeparate' in that specification. | Recommendation | Initial definition. |
| OpenGL ES 2.0 The definition of 'glStencilOpSeparate' in that specification. | Standard | Man page of the OpenGL API. |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 9 | 12 | 4 | 11 | 12 | 5.1 |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | 25 | Yes | Yes | 12 | 8.1 | Yes |
WebGLRenderingContext.stencilOp()WebGLRenderingContext.stencilFunc()WebGLRenderingContext.stencilFuncSeparate()WebGLRenderingContext.stencilMask()WebGLRenderingContext.stencilMaskSeparate()
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/stencilOpSeparate