blob: 20be6a8f7dd2c1bf3e0cf22a7fcde1fd7190fc39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
title: WebGLRenderingContext.bindAttribLocation()
slug: Web/API/WebGLRenderingContext/bindAttribLocation
tags:
- WebGL
- WebGLRenderingContext
translation_of: Web/API/WebGLRenderingContext/bindAttribLocation
---
<p>{{APIRef("WebGL")}}</p>
<p>WebGL API的WebGLRenderingContext.bindAttribLocation()方法将通用顶点索引绑定到属性变量。</p>
<h2 id="语法">语法</h2>
<pre>void <var>gl</var>.bindAttribLocation(<var>program</var>, <var>index</var>, <var>name</var>);
</pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>program</code></dt>
<dd>要绑定的{{domxref("WebGLProgram")}} 对象。</dd>
<dt>index</dt>
<dd>{{domxref("GLuint")}} 指定要绑定的通用顶点的索引。</dd>
<dt>name</dt>
<dd>{{domxref("DOMString")}}指定要绑定到通用顶点索引的变量的名称。 该名称不能以“webgl_”或“_webgl_”开头,因为这些名称将保留供WebGL使用。</dd>
</dl>
<h3 id="返回值">返回值</h3>
<p>None.</p>
<h2 id="示例">示例</h2>
<pre>gl.bindAttribLocation(program, colorLocation, 'vColor');
</pre>
<h2 id="规范">规范</h2>
<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.9", "bindAttribLocation")}}</td>
<td>{{Spec2('WebGL')}}</td>
<td>Initial definition.</td>
</tr>
<tr>
<td>{{SpecName('OpenGL ES 2.0', "glBindAttribLocation.xml", "glBindAttribLocation")}}</td>
<td>{{Spec2('OpenGL ES 2.0')}}</td>
<td>Man page of the (similar) OpenGL API.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容">浏览器兼容</h2>
<p>{{Compat("api/WebGLRenderingContext", "WebGLRenderingContext.bindAttribLocation")}}</p>
<h2 id="另见">另见</h2>
<ul>
<li>{{domxref("WebGLRenderingContext.getActiveAttrib()")}}</li>
<li>{{domxref("WebGLRenderingContext.getAttribLocation()")}}</li>
<li>{{domxref("WebGLRenderingContext.getVertexAttrib()")}}</li>
</ul>
|