glDrawArrays function

The glDrawArrays function specifies multiple primitives to render.

Syntax

void WINAPI glDrawArrays(
   GLenum  mode,
   GLint   first,
   GLsizei count
);

Parameters

mode

The kind of primitives to render. The following constants specify acceptable types of primitives: GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUAD_STRIP, GL_QUADS, and GL_POLYGON.

first

The starting index in the enabled arrays.

count

The number of indexes to render.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

Name Meaning
GL_INVALID_VALUE
count was negative.
GL_INVALID_ENUM
mode was not an accepted value.
GL_INVALID_OPERATION
The function was called between a call to glBegin and the corresponding call to glEnd.

Remarks

With glDrawArrays, you can specify multiple geometric primitives to render. Instead of calling separate OpenGL functions to pass each individual vertex, normal, or color, you can specify separate arrays of vertices, normals, and colors to define a sequence of primitives (all the same kind) with a single call to glDrawArrays.

When you call glDrawArrays, count sequential elements from each enabled array are used to construct a sequence of geometric primitives, beginning with the first element. The mode parameter specifies what kind of primitive to construct and how to use the array elements to construct the primitives.

After glDrawArrays returns, the values of vertex attributes that are modified by glDrawArrays are undefined. For example, if GL_COLOR_ARRAY is enabled, the value of the current color is undefined after glDrawArrays returns. Attributes not modified by glDrawArrays remain defined. When GL_VERTEX_ARRAY is not enabled, no geometric primitives are generated but the attributes corresponding to enabled arrays are modified.

You can include glDrawArrays in display lists. When you include glDrawArrays in a display list, the necessary array data, determined by the array pointers and the enables, are generated and entered in the display list. The values of array pointers and enables are determined during the creation of display lists.

You can read static array data at any time. If any static array elements are modified and the array is not specified again, the results of any subsequent calls to glDrawArrays are undefined.

Although no error is generated when you specify an array more than once within glBegin and glend pairs, the results are undefined.

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Gl.h
Library
Opengl32.lib
DLL
Opengl32.dll

See also

glArrayElement

glBegin

glColorPointer

glEdgeFlagPointer

glEnd

glGetPointerv

glGetString

glIndexPointer

glNormalPointer

glTexCoordPointer

glVertexPointer