From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webglrenderingcontext/vertexattrib/index.html | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 files/zh-cn/web/api/webglrenderingcontext/vertexattrib/index.html (limited to 'files/zh-cn/web/api/webglrenderingcontext/vertexattrib') diff --git a/files/zh-cn/web/api/webglrenderingcontext/vertexattrib/index.html b/files/zh-cn/web/api/webglrenderingcontext/vertexattrib/index.html new file mode 100644 index 0000000000..d511b0c1d8 --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/vertexattrib/index.html @@ -0,0 +1,81 @@ +--- +title: 'WebGLRenderingContext.vertexAttrib[1234]f[v]()' +slug: Web/API/WebGLRenderingContext/vertexAttrib +translation_of: Web/API/WebGLRenderingContext/vertexAttrib +--- +
{{APIRef("WebGL")}}
+ +

 WebGLRenderingContext.vertexAttrib[1234]f[v]() 是 WebGL API 的方法,可以为顶点attibute变量赋值。

+ +

语法

+ +
void gl.vertexAttrib1f(index, v0);
+void gl.vertexAttrib2f(index, v0, v1);
+void gl.vertexAttrib3f(index, v0, v1, v2);
+void gl.vertexAttrib4f(index, v0, v1, v2, v3);
+
+void gl.vertexAttrib1fv(index, value);
+void gl.vertexAttrib2fv(index, value);
+void gl.vertexAttrib3fv(index, value);
+void gl.vertexAttrib4fv(index, value);
+
+ +

Parameters

+ +
+
index
+
 {{domxref("GLuint")}} 类型,指定了待修改顶点attribute变量的存储位置。
+
v0, v1, v2, v3
+
浮点数类型{{jsxref("Number")}},用于设置顶点attibute变量的各分量值。
+
value
+
+

{{jsxref("Float32Array")}} 类型,用于设置顶点attibute变量的向量值。

+
+
+ +

返回值

+ +

无。

+ +

示例

+ +
const a_foobar = gl.getAttribLocation(shaderProgram, 'foobar');
+//either set each component individually:
+gl.vertexAttrib3f(a_foobar, 10.0, 5.0, 2.0);
+//or provide a Float32Array:
+const floatArray = new Float32Array([10.0, 5.0, 2.0]);
+gl.vertexAttrib3fv(a_foobar, floatArray);
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebGL', "#5.14.10", "vertexAttrib")}}{{Spec2('WebGL')}}Initial definition.
{{SpecName('OpenGL ES 2.0', "glVertexAttrib.xml", "glVertexAttrib")}}{{Spec2('OpenGL ES 2.0')}}Man page of the OpenGL API.
+ +

浏览器兼容性

+ + + +

{{Compat("api.WebGLRenderingContext.vertexAttrib1f")}}

+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf