Light | Dark

glMultiDrawElementsIndirectCount

Name

glMultiDrawElementsIndirectCount — render multiple sets of primitives by indexing vertices, taking parameters from memory and the draw count from a buffer

C Specification

void glMultiDrawElementsIndirectCount( GLenum mode,
  GLenum type,
  const void * indirect,
  GLintptr drawcount,
  GLsizei maxdrawcount,
  GLsizei stride);
 

Parameters

mode

Specifies what kind of primitives to render. Symbolic constants GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_LINE_STRIP_ADJACENCY, GL_LINES_ADJACENCY, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_TRIANGLE_STRIP_ADJACENCY, GL_TRIANGLES_ADJACENCY, and GL_PATCHES are accepted.

type

Specifies the type of the values in the element array buffer. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.

indirect

Specifies the address of an array of structures containing the draw parameters.

drawcount

Specifies the offset (in bytes) into the buffer object bound to the GL_PARAMETER_BUFFER binding point at which a single GLsizei typed value is stored, which contains the draw count.

maxdrawcount

Specifies the maximum number of draws that are expected to be stored in the buffer.

stride

Specifies the distance in basic machine units between elements of the draw parameter array.

Description

glMultiDrawElementsIndirectCount behaves similarly to glMultiDrawElementsIndirect, except that the number of draws is not taken from the drawcount parameter, but instead from a buffer object. The offset into this buffer object is given by drawcount.

drawcount defines an offset (in bytes) into the buffer object bound to the GL_PARAMETER_BUFFER binding point at which a single GLsizei typed value is stored, which contains the draw count. maxdrawcount specifies the maximum number of draws that are expected to be stored in the buffer. If the value stored at drawcount into the buffer is greater than maxdrawcount, the implementation stops processing draws after maxdrawcount parameter sets.

indirect specifies a byte offset (cast to a pointer type) into the buffer object bound to the GL_DRAW_INDIRECT_BUFFER target. This buffer contains an array of structures, each providing the parameters for one draw call. Each structure contains the following five parameters:

    typedef  struct {
        uint  count;
        uint  instanceCount;
        uint  firstIndex;
        int   baseVertex;
        uint  baseInstance;
    } DrawElementsIndirectCommand;
            

A single call to glMultiDrawElementsIndirectCount is equivalent to calling glDrawElementsInstancedBaseVertexBaseInstance multiple times, where the parameters for draw i are taken from structure i in the array contained in the buffer bound to the GL_DRAW_INDIRECT_BUFFER binding point, and the number of draws is taken from the GL_PARAMETER_BUFFER.

The maximum number of draw commands that may be specified is implementation dependent, but must be at least 16,384. The number of draw commands actually executed is the minimum of the value stored in the parameter buffer and maxdrawcount.

Notes

The baseInstance member of the DrawElementsIndirectCommand structure is defined only if the GL version is 4.2 or greater. For versions of the GL less than 4.2, this parameter is present but is reserved and should be set to zero. On earlier versions of the GL, behavior is undefined if it is non-zero.

glMultiDrawElementsIndirectCount is available only if the GL version is 4.6 or greater.

Errors

GL_INVALID_ENUM is generated if mode is not an accepted value.

GL_INVALID_ENUM is generated if type is not one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.

GL_INVALID_VALUE is generated if stride is not a multiple of four.

GL_INVALID_VALUE is generated if drawcount is not a multiple of four.

GL_INVALID_VALUE is generated if maxdrawcount is negative.

GL_INVALID_OPERATION is generated if no buffer is bound to the GL_PARAMETER_BUFFER binding point.

GL_INVALID_OPERATION is generated if reading a GLsizei typed value from the buffer bound to the GL_PARAMETER_BUFFER target at the offset specified by drawcount would result in an out-of-bounds access.

GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array and the buffer object's data store is currently mapped.

GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with the input primitive type of the geometry shader in the currently installed program.

GL_INVALID_OPERATION is generated if mode is GL_PATCHES and no tessellation control shader is active.

Associated Gets

glGet with argument GL_DRAW_INDIRECT_BUFFER_BINDING

glGet with argument GL_PARAMETER_BUFFER_BINDING

glGet with argument GL_ELEMENT_ARRAY_BUFFER_BINDING

Version Support

OpenGL Version
Function / Feature Name 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5 4.6
glMultiDrawElementsIndirectCount - - - - - - - - - - - -
Think you can improve this page? Edit this page on GitHub.