Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
When using the XRWebGLLayer()
constructor to create a new WebGL rendering layer for WebXR, providing as the layerInit
parameter an object whose stencil
property is false
requests that the new layer be created without a stencil buffer.
The stencil buffer is an optional buffer which, just like the depth buffer, contains one entry for every pixel in the frame buffer. Also just like the depth buffer, the value of an enter in the stencil buffer directly affects how (or if) the corresponding pixel is drawn during rendering. You can store values into each entry in the stencil bufer, then specify an operation that determines which stencil buffer values correspond to pixels which should be drawn to the screen during each frame.
Syntax
let layerInit = { stencil: false }; let glLayer = new XRWebGLLayer(xrSession, gl, layerInit); let glLayer = new XRWebGLLayer(xrSession, gl, { stencil: false });
Value
A Boolean which can be set to false
to specify that the new WebGL layer should not include a stencil buffer. The default value is true
.
Example
In this example, a new XRWebGLLayer
is created for a WebXR session, xrSession
, without a stencil buffer.
xrSession.updateRenderState({ baseLayer: new XRWebGLLayer(xrSession, gl, { stencil: false }); });
Specifications
Specification | Status | Comment |
---|---|---|
WebXR Device API The definition of 'XRWebGLLayerInit.stencil' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
stencil | Chrome Full support 79 | Edge Full support 79 | Firefox No support No | IE No support No | Opera No support No | Safari No support No | WebView Android Full support 79 | Chrome Android Full support 79 | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android Full support 11.2 |
Legend
- Full support
- Full support
- No support
- No support
See also
- WebXR Device API
- Getting started with WebGL
- WebGL stenciling methods include:
stencilOp()
,clearStencil()
,stencilFunc()
,stencilMask()
,stencilMaskSeparate()
,stencilFuncSeparate()
,stencilOpSeparate()
,