WebGLRenderingContext.stencilOpSeparate() - Web APIs 编辑
The WebGLRenderingContext.stencilOpSeparate()
method of the WebGL API sets the front and/or back-facing stencil test actions.
Syntax
void gl.stencilOpSeparate(face, fail, zfail, zpass);
Parameters
The fail
, zfail
and zpass
parameters accept all constants listed below.
- face
- A
GLenum
specifying whether the front and/or back stencil state is updated. The possible values are:gl.FRONT
gl.BACK
gl.FRONT_AND_BACK
fail
- A
GLenum
specifying the function to use when the stencil test fails. The default value isgl.KEEP
. zfail
- A
GLenum
specifying the function to use when the stencil test passes, but the depth test fails. The default value isgl.KEEP
. zpass
- A
GLenum
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 isgl.KEEP
.
Return value
None.
Constants
gl.KEEP
- Keeps the current value.
gl.ZERO
- Sets the stencil buffer value to 0.
gl.REPLACE
- Sets the stencil buffer value to the reference value as specified by
WebGLRenderingContext.stencilFunc()
. gl.INCR
- Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
gl.INCR_WRAP
- Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value.
gl.DECR
- Decrements the current stencil buffer value. Clamps to 0.
gl.DECR_WRAP
- Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of 0.
gl.INVERT
- Inverts the current stencil buffer value bitwise.
Examples
The 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);
Specifications
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. |
Browser compatibility
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论