aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/webglrenderingcontext/drawarrays
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/drawarrays
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/drawarrays')
-rw-r--r--files/zh-cn/web/api/webglrenderingcontext/drawarrays/index.html93
1 files changed, 93 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/drawarrays/index.html b/files/zh-cn/web/api/webglrenderingcontext/drawarrays/index.html
new file mode 100644
index 0000000000..f27d923833
--- /dev/null
+++ b/files/zh-cn/web/api/webglrenderingcontext/drawarrays/index.html
@@ -0,0 +1,93 @@
+---
+title: WebGLRenderingContext.drawArrays()
+slug: Web/API/WebGLRenderingContext/drawArrays
+tags:
+ - WebGL
+translation_of: Web/API/WebGLRenderingContext/drawArrays
+---
+<div>{{APIRef("WebGL")}}</div>
+
+<p> <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 中的<strong><code>WebGLRenderingContext.drawArrays()</code></strong>方法用于从向量数组中绘制图元。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">void <var>gl</var>.drawArrays(<var>mode</var>, <var>first</var>, <var>count</var>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>mode</code></dt>
+ <dd>{{domxref("GLenum")}} 类型,指定绘制图元的方式,可能值如下。
+ <ul>
+ <li><code>gl.POINTS</code>: 绘制一系列点。</li>
+ <li><code>gl.LINE_STRIP</code>: 绘制一个线条。即,绘制一系列线段,上一点连接下一点。</li>
+ <li><code>gl.LINE_LOOP</code>: 绘制一个线圈。即,绘制一系列线段,上一点连接下一点,并且最后一点与第一个点相连。</li>
+ <li><code>gl.LINES</code>: 绘制一系列单独线段。每两个点作为端点,线段之间不连接。</li>
+ <li><code>gl.TRIANGLE_STRIP</code>:绘制一个<a href="https://en.wikipedia.org/wiki/Triangle_strip">三角带</a>。</li>
+ <li><code>gl.TRIANGLE_FAN</code>:绘制一个<a href="https://en.wikipedia.org/wiki/Triangle_fan">三角扇</a>。</li>
+ <li><code>gl.TRIANGLES</code>: 绘制一系列三角形。每三个点作为顶点。</li>
+ </ul>
+ </dd>
+ <dt>first</dt>
+ <dd>{{domxref("GLint")}} 类型 ,指定从哪个点开始绘制。</dd>
+ <dt>count</dt>
+ <dd>{{domxref("GLsizei")}} 类型,指定绘制需要使用到多少个点。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>无。</p>
+
+<h3 id="异常">异常</h3>
+
+<ul>
+ <li>如果 <code>mode</code> 不是一个可接受值,将会抛出 <code>gl.INVALID_ENUM</code> 异常。</li>
+ <li>如果 <code>first</code> 或者 <code>count</code> 是负值,会抛出 <code>gl.INVALID_VALUE</code> 异常。</li>
+ <li>如果 <code>gl.CURRENT_PROGRAM</code> 为 {{jsxref("null")}},会抛出 <code>gl.INVALID_OPERATION</code> 异常。</li>
+</ul>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">gl.drawArrays(gl.POINTS, 0, 8);
+</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.11", "drawArrays")}}</td>
+ <td>{{Spec2('WebGL')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 2.0', "glDrawArrays.xml", "glDrawArrays")}}</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.drawArrays")}}</p>
+
+<h2 id="另见">另见</h2>
+
+<ul>
+ <li>{{domxref("WebGLRenderingContext.drawElements()")}}</li>
+ <li>{{domxref("ANGLE_instanced_arrays.drawArraysInstancedANGLE()", "ext.drawArraysInstancedANGLE()")}}</li>
+ <li>{{domxref("ANGLE_instanced_arrays.drawElementsInstancedANGLE()", "ext.drawElementsInstancedANGLE()")}}</li>
+ <li>{{domxref("ANGLE_instanced_arrays.vertexAttribDivisorANGLE()", "ext.vertexAttribDivisorANGLE()")}}</li>
+ <li>{{domxref("WebGL2RenderingContext.drawArraysInstanced()")}}</li>
+ <li>{{domxref("WebGL2RenderingContext.drawElementsInstanced()")}}</li>
+ <li>{{domxref("WebGL2RenderingContext.vertexAttribDivisor()")}}</li>
+</ul>