WebGLRenderingContext: useProgram() method

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.

TOK1_

Phương thức WebGLRenderingContext.useProgram() của WebGL API đặt WebGLProgram được chỉ định làm một phần của trạng thái kết xuất hiện tại.

Cú pháp

js
useProgram(program)

Thông số

program

Một WebGLProgram để sử dụng.

Giá trị trả về

Không có (undefined).

Ví dụ

js
const program = gl.createProgram();

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

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

Thông số kỹ thuật

Thông số kỹ thuật
WebGL Specification
# 5.14.9

Khả năng tương thích của trình duyệt

Xem thêm