MDN self-hosted library · e01.org

WebGLRenderingContext: useProgram() method

WebGL

WebGL

The WebGLRenderingContext.useProgram() method of the WebGL API sets the specified WebGLProgram as part of the current rendering state.

Syntax

useProgram(program)

Parameters

  • program
  • : A WebGLProgram to use, or null to clear the current program.

Return value

None (undefined).

Examples

const program = gl.createProgram();

// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);

gl.linkProgram(program);
gl.useProgram(program);

Specifications

Browser compatibility

See also

  • WebGLRenderingContext.createProgram()
  • WebGLRenderingContext.deleteProgram()
  • WebGLRenderingContext.isProgram()
  • WebGLRenderingContext.linkProgram()
  • WebGLRenderingContext.validateProgram()
  • WebGLRenderingContext.getProgramParameter()
  • WebGLRenderingContext.getProgramInfoLog()