GLGETACTIVEATTRIB(3G)

πŸ’… GLGETACTIVEATTRIB (3G) β€” like, the whole manual, bestie

okay so before we even start: this is the 3G manual page (yes the header has a little [FIXME: manual] placeholder in it, we love a work in progress πŸ’€). it's about glGetActiveAttrib, and it's genuinely so useful once it clicks. buckle up. πŸŽ€


✨ NAME ✨

glGetActiveAttrib β€” returns info about an active attribute variable for the program object you point at. that's it, that's the vibe. πŸ¦‹


🌸 C SPECIFICATION 🌸

void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize,
                       GLsizei *length, GLint *size, GLenum *type,
                       GLchar *name);

she's long, she's iconic, copy her exactly. πŸ‘‘


🫢 PARAMETERS 🫢

  • program β€” the program object you're interrogating. like "hey bestie tell me about yourself".
  • index β€” which attribute variable you want. the index of the attribute variable to be queried, specifically.
  • bufSize β€” the max number of characters OpenGL is allowed to write into the character buffer that name points to. no overflowing, we're classy. ✨
  • length β€” returns the number of characters OpenGL actually wrote into the string at name (null terminator not included) β€” but only if you pass it something other than NULL.
  • size β€” returns the size of the attribute variable.
  • type β€” returns the data type of the attribute variable.
  • name β€” returns a null terminated string holding the attribute variable's name.

πŸ’– DESCRIPTION πŸ’–

so glGetActiveAttrib gives you the tea on an active attribute variable inside the program object you named in program. wanna know how many active attributes there even are? call glGetProgram() with GL_ACTIVE_ATTRIBUTES. 🧚

index of 0 picks the first active attribute variable. permissible values for index are from zero up to (number of active attribute variables minus one). math girlie hours. πŸ“

a vertex shader can use built-in attribute variables, user-defined attribute variables, or both:

  • built-in ones have the prefix "gl_" and reference conventional OpenGL vertex attributes (like gl_Vertex, gl_Normal, etc. β€” the OpenGL Shading Language spec has the complete list, iykyk).
  • user-defined ones have arbitrary names and get their values through numbered generic vertex attributes.

an attribute variable (built-in or user-defined, doesn't matter) counts as active if, during the link operation, it's determined that it may be accessed during program execution. so program should already have been the target of a glLinkProgram() call β€” but lowkey it does not need to have linked successfully. πŸ™ˆ

need to know how big a buffer to allocate for the longest attribute variable name in program? call glGetProgram() with GL_ACTIVE_ATTRIBUTE_MAX_LENGTH. use that value to allocate a buffer big enough for the returned attribute name, pass the buffer's size in bufSize, and pass a pointer to it in name. main character buffer energy. πŸ‘‘

glGetActiveAttrib returns the name of the attribute variable indicated by index, storing it in the character buffer specified by name. the string it returns will be null terminated. the actual number of characters written into the buffer comes back in length, and that count does not include the null termination character. don't care about the length? pass NULL in the length argument and move on. πŸ’…

type is a pointer to a variable where the attribute variable's data type gets written. these symbolic constants may be returned:

GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_FLOAT_MAT2,
GL_FLOAT_MAT3, GL_FLOAT_MAT4, GL_FLOAT_MAT2x3, GL_FLOAT_MAT2x4,
GL_FLOAT_MAT3x2, GL_FLOAT_MAT3x4, GL_FLOAT_MAT4x2, GL_FLOAT_MAT4x3,
GL_INT, GL_INT_VEC2, GL_INT_VEC3, GL_INT_VEC4, GL_UNSIGNED_INT,
GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT_VEC3, GL_UNSIGNED_INT_VEC4,
GL_DOUBLE, GL_DOUBLE_VEC2, GL_DOUBLE_VEC3, GL_DOUBLE_VEC4,
GL_DOUBLE_MAT2, GL_DOUBLE_MAT3, GL_DOUBLE_MAT4, GL_DOUBLE_MAT2x3,
GL_DOUBLE_MAT2x4, GL_DOUBLE_MAT3x2, GL_DOUBLE_MAT3x4, GL_DOUBLE_MAT4x2,
GL_DOUBLE_MAT4x3

and size returns the size of the attribute, in units of whatever type came back in type. slay. πŸ”₯

the list of active attribute variables can include both built-in attribute variables (the "gl_" prefix girlies) and user-defined attribute variable names. everyone's invited. 🌈

this function returns as much info as it can about the specified active attribute variable. if no info is available, length will be 0 and name will be an empty string. when does that happen? could occur if you call this function after a link operation that failed. and if an error occurs at all, the return values length, size, type, and name will be left unmodified. 🫢


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.
  • GL_INVALID_OPERATION is generated if program is not a program object.
  • GL_INVALID_VALUE is generated if index is greater than or equal to the number of active attribute variables in program.
  • GL_INVALID_VALUE is generated if bufSize is less than 0.
not the GL_INVALID_VALUE jumpscare 😭 read your args before you call, bestie.

⭐ ASSOCIATED GETS ⭐

  • glGet() with argument GL_MAX_VERTEX_ATTRIBS.
  • glGetProgram() with argument GL_ACTIVE_ATTRIBUTES or GL_ACTIVE_ATTRIBUTE_MAX_LENGTH.
  • glIsProgram()

πŸ‘‘ VERSION SUPPORT πŸ‘‘

glGetActiveAttrib is supported in every one of these OpenGL versions, no skips, no gaps, all checks:

  • 2.0 βœ”
  • 2.1 βœ”
  • 3.0 βœ”
  • 3.1 βœ”
  • 3.2 βœ”
  • 3.3 βœ”
  • 4.0 βœ”
  • 4.1 βœ”
  • 4.2 βœ”
  • 4.3 βœ”
  • 4.4 βœ”
  • 4.5 βœ”

all twelve. she ate and left no crumbs. πŸŽ€βœ¨


πŸ¦‹ SEE ALSO πŸ¦‹

glBindAttribLocation(), glLinkProgram(), glVertexAttrib(), glVertexAttribPointer()


Copyright Β© 2003-2005 3Dlabs Inc. Ltd. 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 Β© 2003-2005 3Dlabs Inc. Ltd. Copyright Β© 2010-2014 Khronos Group


and that's the whole page, periodt πŸ’œ β€” sourced from [FIXME: source], dated 08/09/2021, filed under GLGETACTIVEATTRIB(3G). go query some attributes, you've got this 🌸🫢πŸ”₯

πŸ“¦ where this page comes from