XRWebGLLayerInit.stencil

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

BCD tables only load in the browser

See also