WebGLRenderingContext: Methode getShaderPrecisionFormat()

Baseline Widely available

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

Hinweis: Diese Funktion ist in Web Workers verfügbar.

Die Methode WebGLRenderingContext.getShaderPrecisionFormat() der WebGL API gibt ein neues WebGLShaderPrecisionFormat-Objekt zurück, das den Bereich und die Präzision für das angegebene numerische Format des Shaders beschreibt.

Syntax

js
getShaderPrecisionFormat(shaderType, precisionType)

Parameter

shaderType

Entweder ein gl.FRAGMENT_SHADER oder ein gl.VERTEX_SHADER.

precisionType

Ein Präzisionstyp-Wert. Entweder gl.LOW_FLOAT, gl.MEDIUM_FLOAT, gl.HIGH_FLOAT, gl.LOW_INT, gl.MEDIUM_INT oder gl.HIGH_INT.

Rückgabewert

Ein WebGLShaderPrecisionFormat-Objekt oder null, falls ein Fehler auftritt.

Ausnahmen

  • gl.INVALID_ENUM, wenn die Shader- oder Präzisionstypen nicht erkannt werden.
  • gl.INVALID_OPERATION, wenn der Shader-Compiler nicht unterstützt wird.

Beispiele

Der folgende Code ermittelt das Präzisionsformat eines gl.VERTEX_SHADER mit einem gl.MEDIUM_FLOAT-Präzisionstyp.

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

gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT);
// WebGLShaderPrecisionFormat { rangeMin: 127, rangeMax: 127, precision: 23 }

Spezifikationen

Specification
WebGL Specification
# 5.14.9

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getShaderPrecisionFormat

Legend

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

Full support
Full support

Siehe auch