WebGLRenderingContext: drawingBufferColorSpace property
Baseline 2024Newly available
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 inWeb Workers.
TheWebGLRenderingContext.drawingBufferColorSpace property specifies the color space of the WebGL drawing buffer. Along with the default (srgb), thedisplay-p3 color space can be used.
SeeWebGLRenderingContext.unpackColorSpace for specifying the color space for textures.
In this article
Value
This property can have the following values:
"srgb"selects thesRGB color space. This is the default value."display-p3"selects thedisplay-p3 color space.
If an invalid value is specified, then the value ofdrawingBufferColorSpace will remain unchanged.
Examples
>Setting the drawing buffer color space to draw a Display P3 red
js
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);Specifications
| Specification |
|---|
| WebGL Specification> # DOM-WebGLRenderingContext-drawingBufferColorSpace> |