files/en-us/web/api/webglrenderingcontext/drawarrays/index.md
{{APIRef("WebGL")}}{{AvailableInWorkers}}
The WebGLRenderingContext.drawArrays() method of the WebGL API renders primitives from array data.
drawArrays(mode, first, count)
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_STRIPgl.TRIANGLE_FANgl.TRIANGLES: Draws a triangle for a group of three vertices.[!NOTE] If
modeisPOINTS,gl_PointSizemay need to be set fordrawArraysto render, as its value is unknown if not explicitly written. Only some GPUs set its default as1.0.
first
count
None ({{jsxref("undefined")}}).
mode is not one of the accepted values, a
gl.INVALID_ENUM error is thrown.first or count are negative, a
gl.INVALID_VALUE error is thrown.gl.CURRENT_PROGRAM is null, a
gl.INVALID_OPERATION error is thrown.gl.drawArrays(gl.POINTS, 0, 8);
{{Specifications}}
{{Compat}}