Secure contextThis feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The XRWebGLLayerInit
dictionary's framebufferScaleFactor
property, when specified upon instantiating a new XRWebGLLayer
using its constructor, XRWebGLLayer()
, specifies the scaling factor to use when determining the size of the frame buffer to use when rendering the scene, relative to the default XR device display resolution.
For example, a value of 1.0 indicates that the frame buffer should be the same resolution as the actual display, while a value of 0.5 indicates that the frame buffer should be half the resolution of the display. A value of 2.0, on the other hand, creates a frame buffer whose resolution is double that of the actual display buffer.
There are valid use cases for all of these kinds of scaling. See Managing rendering quality in WebXR performance guide for more information.
You can determine the scaling factor that you would need to apply to match the default frame buffer resolution by using the XRWebGLLayer.getNativeFramebufferScaleFactor()
static function.
Syntax
let layerInit = {
framebufferScaleFactor: scaleFactor
};
let glLayer = new XRWebGLLayer(xrSession, gl, layerInit);
let glLayer = new XRWebGLLayer(xrSession, gl, { framebufferScaleFactor: scaleFactor });
Value
A floating-point value indicating a multiplier to apply to the default frame buffer resolution in order to determine the resolution of the frame buffer for the XRWebGLLayer
.
Example
In this example, a new XRWebGLLayer
is created for a WebXR session, xrSession
, with a frame buffer whose resolution is half that of the default display resolution of the XR device.
xrSession.updateRenderState({
baseLayer: new XRWebGLLayer(xrSession, gl, {
framebufferScaleFactor: 0.5
});
});
Specifications
Specification | Status | Comment |
WebXR Device APIThe definition of 'XRWebGLLayerInit.framebufferScaleFactor' in that specification. | Working Draft | Initial definition. |
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
framebufferScaleFactor
|
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
- WebXR performance guide
XRWebGLLayer.getNativeFramebufferScaleFactor()
XRWebGLLayerInit.framebufferScaleFactor by Mozilla Contributors is licensed under CC-BY-SA 2.5.