--- title: WebGLRenderingContext.shaderSource() slug: Web/API/WebGLRenderingContext/shaderSource translation_of: Web/API/WebGLRenderingContext/shaderSource ---
WebGL API 中的 WebGLRenderingContext.shaderSource()
方法用于设置 {{domxref("WebGLShader")}} 着色器(顶点着色器及片元着色器)的GLSL程序代码。
void gl.shaderSource(shader, source);
None.
var shader = gl.createShader(gl.VERTEX_SHADER); gl.shaderSource(shader, originalSource); var source = gl.getShaderSource(shader);
Specification | Status | Comment |
---|---|---|
{{SpecName('WebGL', "#5.14.9", "shaderSource")}} | {{Spec2('WebGL')}} | Initial definition. |
{{SpecName('OpenGL ES 2.0', "glShaderSource.xml", "glShaderSource")}} | {{Spec2('OpenGL ES 2.0')}} | Man page of the (similar) 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.shaderSource")}}