WebGLRenderingContext.attachShader()

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

Syntaxe

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.

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

BCD tables only load in the browser

Voir aussi