GLUNIFORMBLOCKBINDIN(3G)

πŸ’… glUniformBlockBinding (3G) ✨

okay so bestie, welcome to the OpenGL corner of the manual pages β€” section 3G, the GL function pages, and today's main character is glUniformBlockBinding. she's the one who tells a uniform block exactly which binding point it's gonna live at. no cap. πŸŽ€


🌸 NAME 🌸

glUniformBlockBinding β€” assign a binding point to an active uniform block 🫢


✨ C SPECIFICATION ✨

void glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex,
                           GLuint uniformBlockBinding);
literally copy that signature exactly, bestie. three GLuints, no vibes-based improvising. πŸ’…

πŸ¦‹ PARAMETERS πŸ¦‹

  • program β€” the name of a program object that contains the active uniform block whose binding you're assigning. like, the program holding the block. πŸ’–
  • uniformBlockIndex β€” the index of the active uniform block within program whose binding you're assigning. yep, it's an index, not a name. iykyk. ✨
  • uniformBlockBinding β€” the actual binding point you want to bind the uniform block with index uniformBlockIndex within program to. this is the destination, queen. πŸ‘‘

🌈 DESCRIPTION 🌈

so binding points for active uniform blocks get assigned with glUniformBlockBinding. every active uniform block in a program has a matching uniform buffer binding point β€” think of it as her designated seat. πŸ’Ί

program is the name of a program object for which the command glLinkProgram() has been issued in the past. past tense, bestie β€” she has to have been linked already. πŸ”—

if everything goes well, glUniformBlockBinding specifies that program will use the data store of the buffer object bound to the binding point uniformBlockBinding to extract the values of the uniforms in the uniform block identified by uniformBlockIndex. so: buffer object at that binding point β†’ data store β†’ pull the uniform values out of it. that's the whole pipeline. ate. πŸ’…

🚨 real talk though: when a program object is linked or re-linked, the uniform buffer object binding point assigned to each of its active uniform blocks is reset to zero. every single one. so don't be out here thinking your bindings survived a re-link, because they did not. 😭

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program. that index isn't hers. πŸ™ˆ
  • GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS. out of range, babe. πŸ“
  • GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL. not a real program, not a real problem-solver. βœ‹

πŸ“ NOTES πŸ“

glUniformBlockBinding is available only if the GL version is 3.1 or greater. so check your version first, bestie, or this whole thing is giving nothing. 🧚


πŸ” ASSOCIATED GETS πŸ”

  • glGetActiveUniformBlock() with argument GL_UNIFORM_BLOCK_BINDING β€” this is how you peek at the current binding. lowkey useful. ⭐

πŸ‘‘ VERSION SUPPORT πŸ‘‘

the original ships this as a big grid, but we're doing it as a list because tables are not it. the columns were OpenGL versions 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, and the row was glUniformBlockBinding:

  • 2.0 β€” ✘ (-)
  • 2.1 β€” ✘ (-)
  • 3.0 β€” ✘ (-)
  • 3.1 β€” βœ”
  • 3.2 β€” βœ”
  • 3.3 β€” βœ”
  • 4.0 β€” βœ”
  • 4.1 β€” βœ”
  • 4.2 β€” βœ”
  • 4.3 β€” βœ”
  • 4.4 β€” βœ”
  • 4.5 β€” βœ”

so like β€” she shows up at 3.1 and then never leaves. loyal. 🫢


🌸 SEE ALSO 🌸

  • glLinkProgram()
  • glBindBufferBase()
  • glBindBufferRange()
  • glGetActiveUniformBlock()

go read those too, bestie, they're all in the same 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


k that's the whole page!! πŸ’– the source line is [FIXME: source], it was dated 08/09/2021, and the page goes by GLUNIFORMBLOCKBINDIN(3G) up top and down at the bottom. slay, go bind some uniform blocks responsibly. βœ¨πŸ¦‹πŸ“
πŸ“¦ where this page comes from