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 are 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. that's the full guest list πŸ’…
  • count β€” how many elements get rendered. the headcount, basically.
  • type β€” the type of the values sitting in indices. must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_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 by glDrawElements have an unspecified value after glDrawElements returns. 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_ENUM is generated if mode is not an accepted value. (you gave her a shape she doesn't recognize. rude.)
  • GL_INVALID_VALUE is generated if count is negative. negative elements are not a thing, bestie, please.
  • 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 object. mismatch energy. it's giving conflict. πŸ™ˆ
  • GL_INVALID_OPERATION is 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 Β© 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