GLMULTIDRAWELEMENTS(3G)

πŸ’– NAME πŸ’–

ok so glMultiDrawElements β€” it renders multiple sets of primitives by, like, specifying indices of array data elements ✨ bestie this is the one that saves you a million function calls 🫢

this one lives in the 3G manual section, and it's giving main character OpenGL energy ngl πŸ‘‘


🌸 C SPECIFICATION 🌸

void glMultiDrawElements(GLenum mode, const GLsizei * count,
                         GLenum type, const GLvoid * const * indices,
                         GLsizei drawcount);

copy it exactly, okay? every pointer and const matters πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • mode β€” tells GL what kind of primitives to render. accepted values 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 whole guest list, no plus-ones.
  • count β€” points to an array of the elements counts. like, how many indices per batch, one entry per draw πŸ‘€
  • type β€” the type of the values in indices. has to be exactly one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. pick wrong and it's not gonna slay 😭
  • indices β€” a pointer to the location where the indices are stored πŸ—‚οΈ
  • drawcount β€” the size of the count and indices arrays. iykyk 🌈

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so glMultiDrawElements specifies multiple sets of geometric primitives with, like, very few subroutine calls. no cap πŸ”₯

instead of calling a GL function to pass every single individual vertex, normal, texture coordinate, edge flag, or color β€” which is exhausting, literally β€” 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 glMultiDrawElements. one call. ONE. we love efficiency πŸ’…βœ¨

glMultiDrawElements is identical in operation to glDrawElements() except that drawcount separate lists of elements are specified. that's it, that's the whole difference, periodt 🎯

vertex attributes that are modified by glMultiDrawElements have an unspecified value after glMultiDrawElements returns. yeah, unspecified β€” don't come for me, that's what the spec says πŸ™ˆ. attributes that aren't modified maintain their previous values though, so those ones are safe 🌸


🧚 NOTES 🧚

GL_LINE_STRIP_ADJACENCY, GL_LINES_ADJACENCY, GL_TRIANGLE_STRIP_ADJACENCY and GL_TRIANGLES_ADJACENCY are available only if the GL version is 3.2 or greater ⭐ like, don't try it on your 2.1 build and then act surprised, bestie πŸ’€


πŸ’œ ERRORS πŸ’œ

  • GL_INVALID_ENUM is generated if mode is not an accepted value 🚫
  • GL_INVALID_VALUE is generated if drawcount is negative. negative draws are not a vibe, they're an error 😀
  • 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 🫠
fr fr check your errors, the group chat does not want to debug your blank screen at 3am 😭

πŸ‘‘ VERSION SUPPORT πŸ‘‘

like the table said, but make it a list because we're cute like that πŸŽ€

  • Function / Feature Name: glMultiDrawElements
  • OpenGL Version support: βœ” in 2.0, βœ” in 2.1, βœ” in 3.0, βœ” in 3.1, βœ” in 3.2, βœ” in 3.3, βœ” in 4.0, βœ” in 4.1, βœ” in 4.2, βœ” in 4.3, βœ” in 4.4, βœ” in 4.5

she ate and left zero crumbs β€” all twelve versions, every single checkmark πŸ’…βœ¨


🌈 SEE ALSO 🌈

  • glDrawArrays()
  • glDrawRangeElements()

go read those too, they're the supporting cast and they're iconic in their own right 🫢


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 Β© 2010-2014 Khronos Group


and that's the whole page, bestie πŸŽ€ source is [FIXME: source], dated 08/09/2021, and it's the GLMULTIDRAWELEMENTS(3G) page β€” mwah, go draw some triangles πŸ’–πŸ’…βœ¨

πŸ“¦ where this page comes from