--- title: WebGLRenderingContext.useProgram() slug: Web/API/WebGLRenderingContext/useProgram translation_of: Web/API/WebGLRenderingContext/useProgram ---
WebGLRenderingContext.useProgram()
方法将定义好的{{domxref("WebGLProgram")}} 对象添加到当前的渲染状态中。
void gl.useProgram(program);
无.
var program = gl.createProgram(); // Attach pre-existing shaders gl.attachShader(program, vertexShader); gl.attachShader(program, fragmentShader); gl.linkProgram(program); gl.useProgram(program);
Specification | Status | Comment |
---|---|---|
{{SpecName('WebGL', "#5.14.9", "useProgram")}} | {{Spec2('WebGL')}} | 原始定义. |
{{SpecName('OpenGL ES 2.0', "glUseProgram.xml", "glUseProgram")}} | {{Spec2('OpenGL ES 2.0')}} | OpenGL API主页. |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("api.WebGLRenderingContext.useProgram")}}