WEBGL_debug_shaders: getTranslatedShaderSource() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

The WEBGL_debug_shaders.getTranslatedShaderSource() method is part of the WebGL API and allows you to debug a translated shader.

Syntax

js
getTranslatedShaderSource(shader)

Parameters

shader

A WebGLShader to get the translated source from.

Return value

A String containing the translated shader source. An empty string is returned, if:

Examples

js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");

const shader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(
  shader,
  "void main() { gl_FragColor = vec4(gl_FragCoord.x, 0.0, 0.0, 1.0); }",
);
gl.compileShader(shader);

const src = gl
  .getExtension("WEBGL_debug_shaders")
  .getTranslatedShaderSource(shader);
console.log(src);
// "void main(){
// (gl_FragColor = vec4(gl_FragCoord.x, 0.0, 0.0, 1.0));
// }"

Specifications

Specification
WebGL WEBGL_debug_shaders Khronos Ratified Extension Specification

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getTranslatedShaderSource
Chrome – Full support
Chrome 47 (Release date: 2015-12-01)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 56 (Release date: 2017-09-28)
footnote Full support
Opera – Full support
Opera 34 (Release date: 2015-12-08)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 47 (Release date: 2015-12-02)
footnote Full support
Firefox for Android – Full support
Firefox for Android 56 (Release date: 2017-09-28)
footnote Full support
Opera Android – Full support
Opera Android 34 (Release date: 2015-12-16)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 47 (Release date: 2015-12-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also