Since October 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Note: This feature is available in Web Workers.
The WebGL2RenderingContext.drawingBufferColorSpace property specifies the color space of the WebGL drawing buffer. Along with the default (srgb), the display-p3 color space can be used.
See WebGL2RenderingContext.unpackColorSpace for specifying the color space for textures.
This property can have the following values:
"srgb" selects the sRGB color space. This is the default value."display-p3" selects the display-p3 color space.If an invalid value is specified, then the value of drawingBufferColorSpace will remain unchanged.
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.drawingBufferColorSpace = "display-p3";
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
drawingBufferColorSpace |
104 | 104 | 132127–130Accidental early exposure with no functionality. |
90 | 16.4 | 104 | 132127–130Accidental early exposure with no functionality. |
71 | 16.4 | 20.0 | 104 | 16.4 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/drawingBufferColorSpace