WebGLRenderingContext: getActiveAttrib()-Methode

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 WebGLRenderingContext.getActiveAttrib()-Methode der WebGL-API gibt ein WebGLActiveInfo-Objekt zurück, das Größe, Typ und Name eines Vertex-Attributs enthält. Sie wird im Allgemeinen verwendet, um unbekannte Attribute entweder für Debugging-Zwecke oder bei der Erstellung generischer Bibliotheken abzufragen.

Syntax

js
getActiveAttrib(program, index)

Parameter

program

Ein WebGLProgram, das das Vertex-Attribut enthält.

index

Ein GLuint, der den Index des abzurufenden Vertex-Attributs angibt. Dieser Wert ist ein Index von 0 bis N - 1, wie er durch gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES) zurückgegeben wird.

Rückgabewert

Ein WebGLActiveInfo-Objekt.

Beispiele

js
const numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
for (let i = 0; i < numAttribs; ++i) {
  const info = gl.getActiveAttrib(program, i);
  console.log("name:", info.name, "type:", info.type, "size:", info.size);
}

Spezifikationen

Specification
WebGL Specification
# 5.14.10

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
getActiveAttrib

Legend

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

Full support
Full support

Siehe auch