WebGLRenderingContext.vertexAttrib[1234]f[v]()

这篇翻译不完整。请帮忙从英语翻译这篇文章

 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
 GLuint 类型,指定了待修改顶点attribute变量的存储位置。
v0, v1, v2, v3
浮点数类型Number,用于设置顶点attibute变量的各分量值。
value

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);

规范

Specification Status Comment
WebGL 1.0
vertexAttrib
Recommendation Initial definition.
OpenGL ES 2.0
glVertexAttrib
Standard Man page of the OpenGL API.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 9Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support 25Edge Mobile Full support YesFirefox Android Full support YesOpera Android Full support 12Safari iOS Full support 8.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support

相关链接

文档标签和贡献者

此页面的贡献者: qdlaoyao
最后编辑者: qdlaoyao,