WebGLRenderingContext.attachShader()

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.

La méthode WebGLRenderingContext.attachShader() de l'API WebGL attache un WebGLShader de fragment ou de sommet à un WebGLProgram.

Syntaxe

js
void gl.attachShader(programme, shader);

Paramètres

programme

Un WebGLProgram.

shader

Un WebGLShader de fragment ou de sommet.

Exemples

Le code suivant attache des shaders pré-existants à un WebGLProgram.

js
var programme = gl.createProgram();

// Attacher des shaders pré-existants
gl.attachShader(programme, shaderDeSommet);
gl.attachShader(programme, shaderDeFragment);

gl.linkProgram(programme);

if (!gl.getProgramParameter(programme, gl.LINK_STATUS)) {
  var info = gl.getProgramInfoLog(programme);
  throw "Impossible de compiler le program WebGL. \n\n" + info;
}

Spécifications

Specification
WebGL Specification
# 5.14.9

Compatibilité des navigateurs

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
attachShader

Legend

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

Full support
Full support

Voir aussi