GLDRAWELEMENTSINSTAN(3G)

πŸ’… GLDRAWELEMENTSINSTAN(3G)

okay so bestie, welcome to the 3G manual page, and buckle up because this function name is a whole mouthful 😭 β€” say it with me: glDrawElementsInstancedBaseVertexBaseInstance. Iconic. Unhinged. Ate. Periodt.

✨ NAME ✨

glDrawElementsInstancedBaseVertexBaseInstance β€” render multiple instances of a set of primitives from array data with a per-element offset 🫢


πŸŽ€ C SPECIFICATION πŸŽ€

void glDrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
                                                   GLsizei count,
                                                   GLenum type,
                                                   GLvoid *indices,
                                                   GLsizei primcount,
                                                   GLint basevertex,
                                                   GLuint baseinstance);

🌸 PARAMETERS 🌸

  • mode β€” tells the GPU what kinda primitives we're serving today πŸ‘‘. Accepted values are GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_LINES_ADJACENCY, GL_LINE_STRIP_ADJACENCY, GL_TRIANGLES_ADJACENCY, GL_TRIANGLE_STRIP_ADJACENCY and GL_PATCHES.
  • count β€” the number of elements to be rendered. literally how many we're drawing ✨
  • type β€” the type of the values in indices. bestie it must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. no substitutions, this is a vibe check and they all pass πŸ’…
  • indices β€” a pointer to the location where the indices are stored πŸ“
  • primcount β€” the number of instances of the indexed geometry that should be drawn. yes, we're doing it multiple times, main character energy πŸ”₯
  • basevertex β€” a constant that should be added to each element of indices when choosing elements from the enabled vertex arrays. it's giving "offset but make it a whole personality" πŸ¦‹
  • baseinstance β€” the base instance for use in fetching instanced vertex attributes 🌈

πŸ’œ DESCRIPTION πŸ’œ

So glDrawElementsInstancedBaseVertexBaseInstance behaves identically to glDrawElementsInstanced() β€” same energy, same job β€” except that the i-th element transferred by the corresponding draw call will be taken from element indices[i] + basevertex of each enabled array. Cute, right? πŸŽ€

Now, if the resulting value is larger than the maximum value representable by type, it is as if the calculation were upconverted to 32-bit unsigned integers (with wrapping on overflow conditions). ⚠️ And the operation is undefined if the sum would be negative β€” like, actually undefined, don't do that, no cap πŸ’€

Specific vertex attributes may be classified as instanced through the use of glVertexAttribDivisor(). Instanced vertex attributes supply per-instance vertex data to the vertex shader ✨ The index of the vertex fetched from the enabled instanced vertex attribute arrays is calculated as gl _ InstanceID divisor + baseInstance. Note that baseinstance does not affect the shader-visible value of gl_InstanceID πŸ™ˆ

πŸ¦‹ NOTES πŸ¦‹

glDrawElementsInstancedBaseVertex is only supported if the GL version is 3.2 or greater. that's the rule, bestie 🫢

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM β€” generated if mode is not an accepted value. wrong vibe, rejected 😭
  • GL_INVALID_VALUE β€” generated if count or primcount is negative. negative?? not on my watch πŸ™ˆ
  • GL_INVALID_OPERATION β€” 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. they're not matching and the GPU is not having it πŸ”₯
  • GL_INVALID_OPERATION β€” 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. bestie it's mapped, put it back 😭

⭐ VERSION SUPPORT ⭐

Feature name: glDrawElementsInstancedBaseVertexBaseInstance β€” here's the whole glow-up timeline, no skips:

  • 2.0 β€” - (nope)
  • 2.1 β€” - (nope)
  • 3.0 β€” - (nope)
  • 3.1 β€” - (nope)
  • 3.2 β€” - (nope)
  • 3.3 β€” - (nope)
  • 4.0 β€” - (nope)
  • 4.1 β€” - (nope)
  • 4.2 β€” βœ” (hello πŸ‘‘)
  • 4.3 β€” βœ”
  • 4.4 β€” βœ”
  • 4.5 β€” βœ”

so yeah, 4.2 and up is where she lives πŸ’…

🐚 SEE ALSO 🐚

glDrawElements(), glDrawRangeElements(), glDrawRangeElementsBaseVertex(), glDrawElementsInstanced(), glDrawElementsInstancedBaseVertex()

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


okay that's the whole page bestie, you're officially educated πŸ’– mwah πŸ’‹ β€” this cutie was served up from [FIXME: source], dated 08/09/2021, and yes the page is still called GLDRAWELEMENTSINSTAN(3G) because we respect the name 😌✨

πŸ“¦ where this page comes from