-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
71 lines (51 loc) · 2.14 KB
/
index.md
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
71
---
title: "WebGL2RenderingContext: drawArraysInstanced() method"
short-title: drawArraysInstanced()
slug: Web/API/WebGL2RenderingContext/drawArraysInstanced
page-type: web-api-instance-method
browser-compat: api.WebGL2RenderingContext.drawArraysInstanced
---
{{APIRef("WebGL")}}
The **`WebGL2RenderingContext.drawArraysInstanced()`** method
of the [WebGL 2 API](/en-US/docs/Web/API/WebGL_API) renders primitives from
array data like the {{domxref("WebGLRenderingContext.drawArrays()", "gl.drawArrays()")}}
method. In addition, it can execute multiple instances of the range of elements.
> **Note:** When using {{domxref("WebGLRenderingContext", "WebGL 1", "", 1)}},
> the {{domxref("ANGLE_instanced_arrays")}} extension can provide this method,
> too.
## Syntax
```js-nolint
drawArraysInstanced(mode, first, count, instanceCount)
```
### Parameters
- `mode`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the type primitive to render. Possible values
are:
- `gl.POINTS`: Draws a single dot.
- `gl.LINE_STRIP`: Draws a straight line to the next vertex.
- `gl.LINE_LOOP`: Draws a straight line to the next vertex, and
connects the last vertex back to the first.
- `gl.LINES`: Draws a line between a pair of vertices.
- [`gl.TRIANGLE_STRIP`](https://en.wikipedia.org/wiki/Triangle_strip)
- [`gl.TRIANGLE_FAN`](https://en.wikipedia.org/wiki/Triangle_fan)
- `gl.TRIANGLES`: Draws a triangle for a group of three vertices.
- `first`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the starting index in the array of vector points.
- `count`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the number of indices to be rendered.
- `instanceCount`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the number of instances of the range of elements
to execute.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.drawArraysInstanced(gl.POINTS, 0, 8, 4);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("ANGLE_instanced_arrays.drawArraysInstancedANGLE()")}}
- {{domxref("WEBGL_multi_draw.multiDrawArraysInstancedWEBGL()")}}