GLARRAYELEMENT(3G)

πŸ“¦ version 24.3.3, in opensuse-leap 16.0

πŸ’… GLARRAYELEMENT β€” bestie's guide to rendering one vertex at a time (3G manual, obvi)

okay so this is the page for glArrayElement from the 3G manual section, and it's genuinely iconic once you get it, let me walk you through it 🫢


✨ NAME ✨

glArrayElement β€” render a vertex using the specified vertex array element 🌸


🌈 C SPECIFICATION 🌈

void glArrayElement( GLint i )

πŸŽ€ PARAMETERS πŸŽ€

  • i β€” this is the index into the enabled vertex data arrays. that's it, that's the whole vibe πŸ’–

πŸ‘‘ DESCRIPTION πŸ‘‘

so glArrayElement commands get used inside glBegin/glEnd pairs, and their whole job is specifying vertex and attribute data for point, line, and polygon primitives. periodt ✨

here's the tea: if GL_VERTEX_ARRAY is enabled when glArrayElement is called, a single vertex gets drawn, using vertex and attribute data taken from location i of the enabled arrays. just one. one lil vertex. but if GL_VERTEX_ARRAY is not enabled, no drawing happens at all β€” but the attributes corresponding to the enabled arrays still get modified. so like, sneaky little state change, no art, no cap πŸ™ˆ

the point of glArrayElement is that you construct primitives by indexing vertex data, rather than by streaming through arrays of data in first-to-last order. because each call specifies only a single vertex, you can explicitly specify per-primitive attributes β€” like, say, a single normal per individual triangle. main character energy for real πŸ‘‘

⚠️ okay this next part is important, don't skip it bestie. changes made to array data between the execution of glBegin and the corresponding execution of glEnd may affect calls to glArrayElement that are made within the same glBegin/glEnd period in non-sequential ways. meaning: a call to glArrayElement that precedes a change to array data may access the changed data, and a call that follows a change to array data may access original data. it's giving chaos, and it's by design 😭

πŸ’œ NOTES πŸ’œ

  • glArrayElement is available only if the GL version is 1.1 or greater. no earlier GL, no function, sorry bestie πŸ’€
  • glArrayElement is included in display lists. if glArrayElement is entered into a display list, the necessary array data (determined by the array pointers and enables) is also entered into the display list. so the data comes along for the ride πŸ¦‹
  • because the array pointers and enables are client-side state, their values affect display lists when the lists are created, not when the lists are executed. lowkey the most important sentence here, write it on your mirror ⭐

πŸ”₯ SEE ALSO πŸ”₯

  • glClientActiveTextureARB(3G)
  • glColorPointer(3G)
  • glDrawArrays(3G)
  • glEdgeFlagPointer(3G)
  • glGetPointerv(3G)
  • glIndexPointer(3G)
  • glInterleavedArrays(3G)
  • glNormalPointer(3G)
  • glTexCoordPointer(3G)
  • glVertexPointer(3G)

and that's the whole page, bestie πŸ’– this was GLARRAYELEMENT from the 3G manual β€” yes, the same name at the top and the bottom, she's consistent like that πŸ’… go index some vertices, you're gonna slay 🌟

πŸ“¦ where this page comes from