GLDRAWELEMENTS(3G)
π GLDRAWELEMENTS(3G) β glDrawElements π
okay bestie, welcome to the GLDRAWELEMENTS(3G) page, section 3G, and honestly? this one's kind of a big deal. it's giving "one call, all the primitives" energy and i'm obsessed. sit down, grab a strawberry π, let's go.
β¨ NAME β¨
glDrawElements β render primitives from array data
π«Ά C SPECIFICATION π«Ά
void glDrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices);
no cap, that's the whole signature. she's compact. she's iconic.
πΈ PARAMETERS πΈ
modeβ tells GL what kind of primitives to render, like, the whole vibe of the shape. the symbolic constants she accepts 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_ADJACENCYandGL_PATCHES. that's the full guest list πcountβ how many elements get rendered. the headcount, basically.typeβ the type of the values sitting inindices. must be one ofGL_UNSIGNED_BYTE,GL_UNSIGNED_SHORT, orGL_UNSIGNED_INT. pick one, bestie, those are the only three allowed.indicesβ a pointer to the location where the indices are stored. that's it, that's the address.
π¦ DESCRIPTION π¦
so glDrawElements specifies multiple geometric primitives with, like, very few subroutine calls. that's the whole point. instead of calling a GL function for every single individual vertex, normal, texture coordinate, edge flag, or color β which would be so tedious, genuinely β you can prespecify separate arrays of vertices, normals, and so on, and then use them to construct a sequence of primitives with a single call to glDrawElements. one call. slay. π₯
when glDrawElements gets called, it uses count sequential elements from an enabled array, starting at indices, to construct a sequence of geometric primitives. mode specifies what kind of primitives are constructed and how the array elements construct these primitives. and if more than one array is enabled? each one is used. everybody's invited, no one gets left on read π
β οΈ important caveat, don't skip this: vertex attributes that are modified byglDrawElementshave an unspecified value afterglDrawElementsreturns. unspecified. undefined-adjacent. do not trust them. attributes that aren't modified maintain their previous values, which is at least something.
π NOTES π
GL_LINE_STRIP_ADJACENCY, GL_LINES_ADJACENCY, GL_TRIANGLE_STRIP_ADJACENCY and GL_TRIANGLES_ADJACENCY? yeah those are available only if the GL version is 3.2 or greater. vintage GL girlies don't get these. sorry π
π ERRORS π
GL_INVALID_ENUMis generated ifmodeis not an accepted value. (you gave her a shape she doesn't recognize. rude.)GL_INVALID_VALUEis generated ifcountis negative. negative elements are not a thing, bestie, please.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. mismatch energy. it's giving conflict. πGL_INVALID_OPERATIONis generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped. (mapped buffer = hands off, she's busy.)
π VERSION SUPPORT π
so the rundown on where glDrawElements shows up: glDrawElements is supported in OpenGL 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4 and 4.5 β that's a β in every single column, all twelve of them. main character function behavior, honestly. she's been there the whole time and she's not leaving. periodt β¨πΊ
π SEE ALSO π
glDrawArrays()glDrawElementsInstanced()glDrawElementsBaseVertex()glDrawRangeElements()
go read those too, iykyk π§
π COPYRIGHT π
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group
okay that's the whole page, you ate that π«Ά just so you know, the source line up top was literally [FIXME: source] (yes, really, FIXME, they left it as a TODO, iconic honestly π) and the date on this one is 08/09/2021, stamped under GLDRAWELEMENTS(3G) β so like, both the header and the footer said GLDRAWELEMENTS(3G) and now you know the whole lore. bye bestie, go render something gorgeous βπ
π¦ 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