GLGETACTIVEUNIFORMBL(3G)

πŸ’… NAME πŸ’…

okay so glGetActiveUniformBlock β€” literally the function that lets you query info about an active uniform block. that's it, that's the whole vibe check πŸŽ€

this one lives in the 3G manual, bestie, so keep that in mind ✨


✨ C SPECIFICATION ✨

void glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex,
                               GLenum pname, GLint *params);

like, copy that exactly, no cap πŸ“‹


🫢 PARAMETERS 🫢

  • program β€” specifies the name of a program containing the uniform block. that's your program object, bestie πŸ’–
  • uniformBlockIndex β€” specifies the index of the uniform block within program. yeah, the index, not the name πŸ”’
  • pname β€” specifies the name of the parameter to query. this is the "what do you wanna know" slot 🌸
  • params β€” specifies the address of a variable to receive the result of the query. this is where the answer goes, so point it somewhere real 🎯

πŸ”₯ DESCRIPTION πŸ”₯

okay so glGetActiveUniformBlockiv retrieves information about an active uniform block within program. literally its whole job πŸ’…

program must be the name of a program object for which the command glLinkProgram() must have been called in the past β€” although it is not required that glLinkProgram() must have succeeded. and yes, the link could have failed because the number of active uniforms exceeded the limit. messy, but valid 😭

uniformBlockIndex is an active uniform block index of program, and must be less than the value of GL_ACTIVE_UNIFORM_BLOCKS. mind that ceiling, bestie 🚧

upon success, the uniform block parameter(s) specified by pname are returned in params. if an error occurs, nothing will be written to params β€” like, zero, nada, ghosted πŸ’€


🌈 the pname menu, item by item 🌈

if pname is GL_UNIFORM_BLOCK_BINDING, then the index of the uniform buffer binding point last selected by the uniform block specified by uniformBlockIndex for program is returned. if no uniform block has been previously specified, zero is returned. default 0, iconic πŸŽ€

if pname is GL_UNIFORM_BLOCK_DATA_SIZE, then the implementation-dependent minimum total buffer object size, in basic machine units, required to hold all active uniforms in the uniform block identified by uniformBlockIndex is returned. and listen β€” it is neither guaranteed nor expected that a given implementation will arrange uniform values as tightly packed in a buffer object. the exception to this is the std140 uniform block layout, which guarantees specific packing behavior and does not require the application to query for offsets and strides. in this case the minimum size may still be queried, even though it is determined in advance based only on the uniform block declaration. so yeah, std140 is the main character here πŸ‘‘

if pname is GL_UNIFORM_BLOCK_NAME_LENGTH, then the total length (including the nul terminator) of the name of the uniform block identified by uniformBlockIndex is returned. including the nul terminator, don't forget that extra byte, bestie πŸ“

if pname is GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, then the number of active uniforms in the uniform block identified by uniformBlockIndex is returned. a count, that's it πŸ’œ

if pname is GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, then a list of the active uniform indices for the uniform block identified by uniformBlockIndex is returned. the number of elements that will be written to params is the value of GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS for uniformBlockIndex. so go query that count first, or you're gonna have a bad time πŸ™ˆ

if pname is GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER, GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER, GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, or GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER then a boolean value indicating whether the uniform block identified by uniformBlockIndex is referenced by the vertex, tessellation control, tessellation evaluation, geometry, fragment or compute programming stages of program, respectively, is returned. yes, one boolean, and the order in that sentence maps to the order of the tokens. matching game, slay βœ…


😭 ERRORS 😭

  • GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program. out of bounds? nope 🚫
  • GL_INVALID_ENUM is generated if pname is not one of the accepted tokens. that token's not on the list, babe πŸ™…
  • GL_INVALID_OPERATION is generated if program is not the name of a program object for which glLinkProgram() has been called in the past. no link, no query, periodt πŸ’€

🌸 NOTES 🌸

glGetActiveUniformBlockiv is available only if the GL version is 3.1 or greater. age check, sorry πŸŽ‚

GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER is accepted only if the GL version is 4.3 or greater. that one's a newer-token privilege, iykyk πŸ”’


πŸ‘‘ VERSION SUPPORT πŸ‘‘

here's the vibe: the function is glGetActiveUniformBlockiv and its support across the OpenGL versions goes like this πŸ’«

  • 2.0 β€” - nope πŸ™…
  • 2.1 β€” - nope πŸ™…
  • 3.0 β€” - nope πŸ™…
  • 3.1 β€” βœ” yes bestie πŸŽ‰
  • 3.2 β€” βœ” πŸŽ‰
  • 3.3 β€” βœ” πŸŽ‰
  • 4.0 β€” βœ” πŸŽ‰
  • 4.1 β€” βœ” πŸŽ‰
  • 4.2 β€” βœ” πŸŽ‰
  • 4.3 β€” βœ” πŸŽ‰
  • 4.4 β€” βœ” πŸŽ‰
  • 4.5 β€” βœ” πŸŽ‰

so it pops off starting at 3.1 and never stops. ate and left no crumbs 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

glGetActiveUniformBlockName(), glGetUniformBlockIndex(), glLinkProgram() β€” go read those too, they're the friend group 🫢


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


ok that's the whole page, bestie, you're officially caught up πŸ’…βœ¨

and a lil sign-off: this cutie came from [FIXME: source], dated 08/09/2021, filed under GLGETACTIVEUNIFORMBL(3G). mwah πŸŽ€πŸ’œ

πŸ“¦ where this page comes from