aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/webglrenderingcontext/bindbuffer
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/webglrenderingcontext/bindbuffer
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/webglrenderingcontext/bindbuffer')
-rw-r--r--files/zh-cn/web/api/webglrenderingcontext/bindbuffer/index.html127
1 files changed, 127 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/bindbuffer/index.html b/files/zh-cn/web/api/webglrenderingcontext/bindbuffer/index.html
new file mode 100644
index 0000000000..bb2b94b886
--- /dev/null
+++ b/files/zh-cn/web/api/webglrenderingcontext/bindbuffer/index.html
@@ -0,0 +1,127 @@
+---
+title: WebGLRenderingContext.bindBuffer()
+slug: Web/API/WebGLRenderingContext/bindBuffer
+tags:
+ - WebGL
+ - WebGLRenderingContext
+ - 绑定Buffer
+translation_of: Web/API/WebGLRenderingContext/bindBuffer
+---
+<div>{{APIRef("WebGL")}}</div>
+
+<p><a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a>的WebGLRenderingContext.bindBuffer()方法将给定的{{domxref("WebGLBuffer")}}绑定到目标。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">void <var>gl</var>.bindBuffer(<var>target</var>, <var>buffer</var>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt>target</dt>
+ <dd> {{domxref("GLenum")}} 指定绑定点(target)。 可能的值:
+ <ul>
+ <li><code>gl.ARRAY_BUFFER</code>: 包含顶点属性的Buffer,如顶点坐标,纹理坐标数据或顶点颜色数据。</li>
+ <li><code>gl.ELEMENT_ARRAY_BUFFER</code>: 用于元素索引的Buffer。</li>
+ <li>当使用 {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}时,可以使用以下值:
+ <ul>
+ <li><code>gl.COPY_READ_BUFFER</code>: 从一个Buffer对象复制到另一个Buffer对象。</li>
+ <li><code>gl.COPY_WRITE_BUFFER</code>: 从一个Buffer对象复制到另一个Buffer对象。</li>
+ <li><code>gl.TRANSFORM_FEEDBACK_BUFFER</code>: Buffer for transform feedback operations.</li>
+ <li><code>gl.UNIFORM_BUFFER</code>: 用于存储统一块的Buffer。</li>
+ <li><code>gl.PIXEL_PACK_BUFFER</code>: 用于像素传输操作的Buffer。</li>
+ <li><code>gl.PIXEL_UNPACK_BUFFER</code>: 用于像素传输操作的Buffer。</li>
+ </ul>
+ </li>
+ </ul>
+ </dd>
+ <dt>buffer</dt>
+ <dd>要绑定的 {{domxref("WebGLBuffer")}} 。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>None.</p>
+
+<h3 id="异常">异常</h3>
+
+<p>只有一个目标可以绑定到给定的 {{domxref("WebGLBuffer")}} 。 尝试将缓冲区绑定到另一个目标将引发 <code>INVALID_OPERATION</code> 错误,并且当前的缓冲区绑定将保持不变。</p>
+
+<p>一个被{{domxref("WebGLRenderingContext.deleteBuffer()", "deleteBuffer")}}标记为删除的{{domxref("WebGLBuffer")}}不可重新被绑定,尝试这样做将生成 <code>INVALID_OPERATION</code> 错误,并且当前绑定将保持不变。</p>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="将缓冲区绑定到目标">将缓冲区绑定到目标</h3>
+
+<pre class="brush: js">var canvas = document.getElementById('canvas');
+var gl = canvas.getContext('webgl');
+var buffer = gl.createBuffer();
+
+gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+</pre>
+
+<h3 id="获取当前绑定">获取当前绑定</h3>
+
+<p>要检查当前的缓冲区绑定,请查询ARRAY_BUFFER_BINDING和ELEMENT_ARRAY_BUFFER_BINDING常量。</p>
+
+<pre class="brush: js">gl.getParameter(gl.ARRAY_BUFFER_BINDING);
+gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
+</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.5", "bindBuffer")}}</td>
+ <td>{{Spec2('WebGL')}}</td>
+ <td>Initial definition for WebGL.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 2.0', "glBindBuffer.xml", "glBindBuffer")}}</td>
+ <td>{{Spec2('OpenGL ES 2.0')}}</td>
+ <td>Man page of the (similar) OpenGL ES 2 API.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('WebGL2', "#3.7.1", "bindBuffer")}}</td>
+ <td>{{Spec2('WebGL2')}}</td>
+ <td>
+ <p>Updated definition for WebGL 2.</p>
+
+ <p>Adds new <code>target</code> buffers:<br>
+ <code>gl.COPY_READ_BUFFER</code>,<br>
+ <code>gl.COPY_WRITE_BUFFER</code>,<br>
+ <code>gl.TRANSFORM_FEEDBACK_BUFFER</code>,<br>
+ <code>gl.UNIFORM_BUFFER</code>,<br>
+ <code>gl.PIXEL_PACK_BUFFER</code>,<br>
+ <code>gl.PIXEL_UNPACK_BUFFER</code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 3.0', "glBindBuffer.xhtml", "glBindBuffer")}}</td>
+ <td>{{Spec2('OpenGL ES 3.0')}}</td>
+ <td>Man page of the (similar) OpenGL ES 3 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", "WebGLRenderingContext.bindBuffer")}}</p>
+
+<h2 id="另见">另见</h2>
+
+<ul>
+ <li>{{domxref("WebGLRenderingContext.createBuffer()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.deleteBuffer()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.isBuffer()")}}</li>
+ <li>Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}</li>
+</ul>