From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webglrenderingcontext/drawelements/index.html | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 files/zh-cn/web/api/webglrenderingcontext/drawelements/index.html (limited to 'files/zh-cn/web/api/webglrenderingcontext/drawelements') diff --git a/files/zh-cn/web/api/webglrenderingcontext/drawelements/index.html b/files/zh-cn/web/api/webglrenderingcontext/drawelements/index.html new file mode 100644 index 0000000000..e0dc9e96c6 --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/drawelements/index.html @@ -0,0 +1,103 @@ +--- +title: WebGLRenderingContext.drawElements() +slug: Web/API/WebGLRenderingContext/drawElements +tags: + - API + - Method + - Reference + - WebGL +translation_of: Web/API/WebGLRenderingContext/drawElements +--- +
{{APIRef("WebGL")}}
+ +

该 WebGLRenderingContext.drawElements() 方法 在 WebGL API 从数组数据渲染图元.

+ +

语法

+ +
void gl.drawElements(mode, count, type, offset);
+
+ +

参数

+ +
+
mode
+
{{domxref("枚举类型")}} 指定要渲染的图元类型。可以是以下类型: +
    +
  • gl.POINTS: 画单独的点。
  • +
  • gl.LINE_STRIP: 画一条直线到下一个顶点。
  • +
  • gl.LINE_LOOP: 绘制一条直线到下一个顶点,并将最后一个顶点返回到第一个顶点.
  • +
  • gl.LINES: 在一对顶点之间画一条线.
  • +
  • gl.TRIANGLE_STRIP
  • +
  • gl.TRIANGLE_FAN
  • +
  • gl.TRIANGLES: 为一组三个顶点绘制一个三角形.
  • +
+
+
count
+
{{domxref("整数型")}} 指定要渲染的元素数量.
+
type
+
{{domxref("枚举类型")}} 指定元素数组缓冲区中的值的类型。可能的值是: +
    +
  • gl.UNSIGNED_BYTE
  • +
  • gl.UNSIGNED_SHORT
  • +
  • 当使用 {{domxref("OES_element_index_uint")}} 扩展时: +
      +
    • gl.UNSIGNED_INT
    • +
    +
  • +
+
+
offset
+
 {{domxref("字节单位")}} 指定元素数组缓冲区中的偏移量。必须是给定类型大小的有效倍数.
+
+ +

返回值

+ +

None.

+ +

异常

+ + + +

例子

+ +
gl.drawElements(gl.POINTS, 8, gl.UNSIGNED_BYTE, 0);
+
+ +

格式

+ + + + + + + + + + + + + + + + + + + +
格式状态注解
{{SpecName('WebGL', "#5.14.11", "drawElements")}}{{Spec2('WebGL')}}建议第一次定义.
{{SpecName('OpenGL ES 2.0', "glDrawElements.xml", "glDrawElements")}}{{Spec2('OpenGL ES 2.0')}}规范 OpenGL 手册
+ +

浏览器兼容

+ + + +

{{Compat("api.WebGLRenderingContext.drawElements")}}

+ +

相关参考

+ + -- cgit v1.2.3-54-g00ecf