diff options
Diffstat (limited to 'files/zh-cn/web/api/webglrenderingcontext/vertexattrib/index.html')
| -rw-r--r-- | files/zh-cn/web/api/webglrenderingcontext/vertexattrib/index.html | 81 |
1 files changed, 81 insertions, 0 deletions
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 +--- +<div>{{APIRef("WebGL")}}</div> + +<p> <strong><code>WebGLRenderingContext.vertexAttrib[1234]f[v]()</code></strong> 是 <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 的方法,可以为顶点attibute变量赋值。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">void <var>gl</var>.vertexAttrib1f(<var>index</var>, <var>v0</var>); +void <var>gl</var>.vertexAttrib2f(<var>index</var>, <var>v0</var>, <var>v1</var>); +void <var>gl</var>.vertexAttrib3f(<var>index</var>, <var>v0</var>, <var>v1</var>, <var>v2</var>); +void <var>gl</var>.vertexAttrib4f(<var>index</var>, <var>v0</var>, <var>v1</var>, <var>v2</var>, <var>v3</var>); + +void <var>gl</var>.vertexAttrib1fv(<var>index</var>, <var>value</var>); +void <var>gl</var>.vertexAttrib2fv(<var>index</var>, <var>value</var>); +void <var>gl</var>.vertexAttrib3fv(<var>index</var>, <var>value</var>); +void <var>gl</var>.vertexAttrib4fv(<var>index</var>, <var>value</var>); +</pre> + +<h3 id="Parameters">Parameters</h3> + +<dl> + <dt><code>index</code></dt> + <dd> {{domxref("GLuint")}} 类型,指定了待修改顶点attribute变量的存储位置。</dd> + <dt><code>v0, v1, v2, v3</code></dt> + <dd>浮点数类型{{jsxref("Number")}},用于设置顶点attibute变量的各分量值。</dd> + <dt><code>value</code></dt> + <dd> + <p>{{jsxref("Float32Array")}} 类型,用于设置顶点attibute变量的向量值。</p> + </dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>无。</p> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">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);</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('WebGL', "#5.14.10", "vertexAttrib")}}</td> + <td>{{Spec2('WebGL')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('OpenGL ES 2.0', "glVertexAttrib.xml", "glVertexAttrib")}}</td> + <td>{{Spec2('OpenGL ES 2.0')}}</td> + <td>Man page of the OpenGL API.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("api.WebGLRenderingContext.vertexAttrib1f")}}</p> + +<h2 id="相关链接">相关链接</h2> + +<ul> + <li>{{domxref("WebGLRenderingContext.getVertexAttrib()")}}</li> +</ul> |
