GLDRAWRANGEELEMENTSB(3G)

πŸ’… GLDRAWRANGEELEMENTSB(3G)

okay so first things first: this page lives in the 3G manual section (yes, that's the OpenGL one, hi bestie 🫢), and its whole name is glDrawRangeElementsBaseVertex. It's a function, it draws stuff, and it has opinions about which indices you're allowed to feed it. Let's get into it ✨


πŸŽ€ NAME

glDrawRangeElementsBaseVertex β€” render primitives from array data with a per-element offset. That's the whole vibe: draw things, but shift every index by a constant. Iconic, lowkey.


🌸 C SPECIFICATION

void glDrawRangeElementsBaseVertex(GLenum mode, GLuint start,
                                   GLuint end, GLsizei count,
                                   GLenum type, GLvoid *indices,
                                   GLint basevertex);

That's the signature, character for character, no cap. Don't touch it, just admire it πŸ¦‹


πŸ’– PARAMETERS

  • mode β€” tells the GPU what kind of primitives to render. 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. That's the whole list, bestie, no substitutions πŸ‘‘
  • start β€” the minimum array index contained in indices. Your floor, basically.
  • end β€” the maximum array index contained in indices. Your ceiling.
  • count β€” how many elements are gonna be rendered. Like, the actual number, pls don't lie to it.
  • type β€” the type of the values sitting inside indices. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. Those three. That's it πŸ’€
  • indices β€” a pointer to the location where the indices are stored. Point at them. Politely.
  • basevertex β€” a constant that gets added to each element of indices when choosing elements from the enabled vertex arrays. It's the little offset that could 🧚

✨ DESCRIPTION

So glDrawRangeElementsBaseVertex is like a restricted form of glDrawElementsBaseVertex(). Think of it as the same girl but with a curfew.

mode, count and basevertex match the corresponding arguments to glDrawElementsBaseVertex(), with one extra constraint: all values in the array indices must lie between start and end, inclusive β€” and that's prior to adding basevertex, okurrr? Index values that lie outside the range [start, end] are treated in the same way as glDrawElementsBaseVertex() does it.

The *i*th element transferred by the corresponding draw call will be taken from element indices[i] + basevertex of each enabled array. Math time πŸ’…

If the resulting value is larger than the maximum value representable by type, it's as if the calculation were upconverted to 32-bit unsigned integers β€” with wrapping on overflow conditions. And heads up: the operation is undefined if the sum would be negative. Not undefined cute, undefined undefined. 🚨


πŸ”₯ ERRORS

  • GL_INVALID_ENUM is generated if mode is not an accepted value. (Check the list above, bestie, it's literally right there.)
  • GL_INVALID_VALUE is generated if count is negative. Negative counts? Not on this GPU's watch.
  • GL_INVALID_VALUE is generated if end < start. Your ceiling can't be lower than your floor, babe.
  • 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.
  • 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.
πŸ’€ the mapped-buffer one gets people constantly. like, unmap it first, diva.

🌈 VERSION SUPPORT

Here's the vibe check on which OpenGL versions show up for glDrawRangeElementsBaseVertex:

  • OpenGL 2.0 β€” - not supported 😭
  • OpenGL 2.1 β€” - not supported 😭
  • OpenGL 3.0 β€” - not supported 😭
  • OpenGL 3.1 β€” - not supported 😭
  • OpenGL 3.2 β€” βœ” supported πŸ’–
  • OpenGL 3.3 β€” βœ” supported πŸ’–
  • OpenGL 4.0 β€” βœ” supported πŸ’–
  • OpenGL 4.1 β€” βœ” supported πŸ’–
  • OpenGL 4.2 β€” βœ” supported πŸ’–
  • OpenGL 4.3 β€” βœ” supported πŸ’–
  • OpenGL 4.4 β€” βœ” supported πŸ’–
  • OpenGL 4.5 β€” βœ” supported πŸ’–

so basically if you're on anything before 3.2, this function is not the moment. 3.2 onwards? she ate. πŸ”₯


πŸ¦‹ SEE ALSO

the whole friend group, fr fr:

  • glDrawElements()
  • glDrawElementsBaseVertex()
  • glDrawRangeElements()
  • glDrawElementsInstanced()
  • glDrawElementsInstancedBaseVertex()

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


okay that's the whole page, mwah πŸ’‹ one last thing though β€” the source is listed as [FIXME: source], dated 08/09/2021, and the header/footer both read GLDRAWRANGEELEMENTSB(3G). so like, the docs themselves are a little unfinished, but honestly? relatable. go draw something gorgeous, bestie πŸŒΈβœ¨πŸŽ€

πŸ“¦ where this page comes from