Applies to: desktop apps only
The glDrawElements function renders primitives from array data.
Syntax
void WINAPI glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices );
Parameters
-
mode
-
The kind of primitives to render. It can assume one of the following symbolic values: 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.
count -
The number of elements to be rendered.
type -
The type of the values in indices. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.
indices -
A pointer to the location where the indices are stored.
Return value
This function does not return a value.
Error codes
The following error codes can be retrieved by the glgetError function.
| Name | Meaning |
|---|---|
|
mode was not an accepted value. |
|
count was a negative value. |
|
The function was called between a call to glBegin and the corresponding call to glEnd. |
Remarks
The glDrawElements function enables you to specify multiple geometric primitives with very few function calls. Instead of calling an OpenGL function to pass each individual vertex, normal, or color, you can specify separate arrays of vertices, normals, and colors beforehand and use them to define a sequence of primitives (all of the same type) with a single call toglDrawElements.
When you call the glDrawElements function, it uses count sequential elements from indices to construct a sequence of geometric primitives. The mode parameter specifies what kind of primitives are constructed, and how the array elements are used to construct these primitives. If GL_VERTEX_ARRAY is not enabled, no geometric primitives are generated.
Vertex attributes that are modified by glDrawElements have an unspecified value after glDrawElements returns. For example, if GL_COLOR_ARRAY is enabled, the value of the current color is undefined after glDrawElements executes. Attributes that aren't modified remain unchanged.
You can include the glDrawElements function in display lists. When glDrawElements is included in a display list, the necessary array data (determined by the array pointers and enables) is also entered into the display list. Because the array pointers and enables are client-side state variables, their values affect display lists when the lists are created, not when the lists are executed.
Note The glDrawElements function is only available in OpenGL version 1.1 or later.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
本文介绍OpenGL函数glDrawElements,该函数用于从数组数据中渲染原始图形。文章详细解释了其语法、参数含义及可能遇到的错误情况,并指出该函数自OpenGL 1.1版本起可用。

1224

被折叠的 条评论
为什么被折叠?



