GLDRAWELEMENTSINDIRE(3G)
π GLDRAWELEMENTSINDIRE(3G) π
okay bestie, so this is the page for glDrawElementsIndirect β it lives in section 3G, manual name situation is [FIXME: manual] (yes, literally, the manual name is a FIXME, iconic behavior honestly), and we're about to make indirect indexed drawing make sense. buckle up π
β¨ NAME β¨
glDrawElementsIndirect β render indexed primitives from array data, taking parameters from memory π§
πΈ C SPECIFICATION πΈ
void glDrawElementsIndirect(GLenum mode, GLenum type,
const void *indirect);
π¦ PARAMETERS π¦
modeβ tells the GPU what kind of primitives to render. the accepted symbolic constants areGL_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, andGL_PATCHES. all of them, no cap β¨typeβ the type of data in the buffer that's bound to theGL_ELEMENT_ARRAY_BUFFERbinding.indirectβ the address of a structure that contains the draw parameters. like, the whole point of this function π
π₯ DESCRIPTION π₯
glDrawElementsIndirect specifies multiple indexed geometric primitives with very few subroutine calls. literally so few calls. main character energy.
it behaves similarly to glDrawElementsInstancedBaseVertexBaseInstance(), except that the parameters to glDrawElementsInstancedBaseVertexBaseInstance() are stored in memory at the address given by indirect. so instead of you passing a million args, the args are just⦠sitting there in memory. lowkey genius.
the parameters addressed by indirect are packed into a structure that takes the form (in C):
typedef struct {
uint count;
uint primCount;
uint firstIndex;
uint baseVertex;
uint baseInstance;
} DrawElementsIndirectCommand;
and glDrawElementsIndirect is equivalent to:
void glDrawElementsIndirect(GLenum mode, GLenum type, const void * indirect) {
const DrawElementsIndirectCommand *cmd = (const DrawElementsIndirectCommand *)indirect;
glDrawElementsInstancedBaseVertexBaseInstance(mode,
cmd->count,
type,
cmd->firstIndex * size-of-type,
cmd->primCount,
cmd->baseVertex,
cmd->baseInstance);
}
if a buffer is bound to the GL_DRAW_INDIRECT_BUFFER binding at the time of a call to glDrawElementsIndirect, then indirect is interpreted as an offset, in basic machine units, into that buffer, and the parameter data is read from the buffer rather than from client memory. read that again β offset, not pointer, when the buffer's there. iykyk π«Ά
β οΈ heads up bestie: indices stored in client memory are not supported. if no buffer is bound to the GL_ELEMENT_ARRAY_BUFFER binding, an error will be generated. not me forgetting to bind a buffer π
the results of the operation are undefined if the reservedMustBeZero member of the parameter structure is non-zero. however, no error is generated in this case. so it'll just silently be weird. π
vertex attributes that are modified by glDrawElementsIndirect have an unspecified value after glDrawElementsIndirect returns. attributes that aren't modified remain well defined. so the ones you touched are in their little mystery era and the ones you didn't are fine π
β 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. so like, keep it zero on the old ones, fr fr π
π ERRORS π
GL_INVALID_ENUMis generated ifmodeis not an accepted value.GL_INVALID_OPERATIONis generated if no buffer is bound to theGL_ELEMENT_ARRAY_BUFFERbinding, or if such a buffer's data store is currently mapped.GL_INVALID_OPERATIONis generated if a non-zero buffer object name is bound to an enabled array or to theGL_DRAW_INDIRECT_BUFFERbinding and the buffer object's data store is currently mapped.GL_INVALID_OPERATIONis generated if a geometry shader is active andmodeis incompatible with the input primitive type of the geometry shader in the currently installed program object.GL_INVALID_OPERATIONis generated ifmodeisGL_PATCHESand no tessellation control shader is active.
π VERSION SUPPORT π
the original ships this as a big cozy table with OpenGL versions running across the top; here it is in list form so it survives terminal rendering π
columns of the table: Function / Feature Name and OpenGL versions 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5.
glDrawElementsIndirectβ2.0:-,2.1:-,3.0:-,3.1:-,3.2:-,3.3:-,4.0:β,4.1:β,4.2:β,4.3:β,4.4:β,4.5:β
so it's giving "4.0 and up only" periodt. before that? a whole row of dashes, sorry babe β
π SEE ALSO π
glDrawArrays(), glDrawArraysInstanced(), glDrawArraysIndirect(), glDrawElements(), glDrawRangeElements(),
π COPYRIGHT π
Copyright Β© 2010-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 2010-2014 Khronos Group.
and that's the whole thing queen πΈ the source line at the bottom of the original is [FIXME: source] and the date stamp is 08/09/2021 β so this page is a FIXME-source, FIXME-manual, 2021-era legend π
π«Ά go bind your buffers and slay β¨
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms