coderef

Color management for WebGL2Baseline · Newly available

The drawingBufferColorSpace and unpackColorSpace properties of WebGL2RenderingContext sets the color representation for the buffer and imported textures, such as "srgb" or "display-p3".

Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Oct 29, 2024.

Browser support

DesktopChrome
1–103Not supported
104+Supportedsince Aug 2, 2022
Current: 155
Edge
12–103Not supported
104+Supportedsince Aug 5, 2022
Current: 154
Firefox
1–131Not supported
132+Supportedsince Oct 29, 2024
Current: 157
Safari
1–16.3Not supported
16.4+Supportedsince Mar 27, 2023
Current: 27
MobileChrome Android
18–103Not supported
104+Supportedsince Aug 2, 2022
Current: 155
Firefox Android
4–131Not supported
132+Supportedsince Oct 29, 2024
Current: 157
Safari iOS
1–16.3Not supported
16.4+Supportedsince Mar 27, 2023
Current: 27

How to use

Every current browser supports this, but it only became Baseline on Oct 29, 2024. Use it as a progressive enhancement, or keep a fallback if you support older devices.

Example

Full syntax and examples are on MDN: drawingBufferColorSpace.

Feature detection

JS · check before using
if ("WebGL2RenderingContext" in globalThis && "drawingBufferColorSpace" in WebGL2RenderingContext.prototype) {
  // WebGL2RenderingContext.drawingBufferColorSpace is available
}

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
WebGL2RenderingContext.drawingBufferColorSpace10410413216.410413216.4
WebGL2RenderingContext.unpackColorSpace104104132✕104132✕