GLBINDFRAGDATALOCATI(3G)

πŸ’… GLBINDFRAGDATALOCATI(3G) πŸ’…

okay so welcome to the glBindFragDataLocationIndexed page bestie β€” it's a 3G manual, and we are gonna get so into it. grab a lil snack πŸ“


✨ NAME ✨

glBindFragDataLocationIndexed β€” binds a user-defined varying out variable to a fragment shader color number and an index. yes, both. she's multifunctional πŸ’…


🧾 C SPECIFICATION 🧾

like, literally exactly this, no cap:

void glBindFragDataLocationIndexed(GLuint program, GLuint colorNumber,
                                   GLuint index, const char *name);

🫢 PARAMETERS 🫢

  • program β€” the name of the program that's holding the varying out variable whose binding you wanna mess with
  • colorNumber β€” the color number you're binding that user-defined varying out variable to 🌈
  • index β€” the index of the color input you're binding the user-defined varying out variable to
  • name β€” the name of the user-defined varying out variable whose binding you're modifying, periodt

πŸ’– DESCRIPTION πŸ’–

So glBindFragDataLocationIndexed is telling you: the varying out variable called name inside program should be bound to fragment color colorNumber the next time that program gets linked. and index can be zero or one β€” zero means that color is used as the first color input to the blend equation, one means it's the second. that's it, that's the assignment πŸŽ€

Now here's the tea: the bindings you set with glBindFragDataLocationIndexed do not do anything until program is linked next. you can set them at literally any time after program has been created β€” specifically, you can even set them before the shader objects get attached to the program. wild, i know 😭 because of that you can pass any name in name, including a name that's never ever used as a varying out variable in any fragment shader object. but heads up β€” names starting with gl_ are reserved by the GL, so don't even try it πŸ™ˆ

If name was already bound before, its binding gets replaced with colorNumber and index. name has to be a null-terminated string. index must be less than or equal to one, and colorNumber must be less than the value of GL_MAX_DRAW_BUFFERS if index is zero, and less than the value of GL_MAX_DUAL_SOURCE_DRAW_BUFFERS if index is greater than or equal to one. math checks out bestie 🧚

And on top of the errors that glBindFragDataLocationIndexed already throws, the program program will straight up fail to link if:

  • the number of active outputs is greater than the value GL_MAX_DRAW_BUFFERS
  • more than one varying out variable is bound to the same color number (chaos, honestly πŸ’€)

πŸ¦‹ NOTES πŸ¦‹

Varying out varyings can have locations assigned explicitly in the shader text using a location layout qualifier. lowkey important: if a shader statically assigns a location to a varying out variable in the shader text, that location is the one that gets used β€” and any location you assigned with glBindFragDataLocation gets ignored. she said "i already picked, thanks" πŸ’…


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_VALUE is generated if colorNumber is greater than or equal to GL_MAX_DRAW_BUFFERS.
  • GL_INVALID_VALUE is generated if colorNumber is greater than or equal to GL_MAX_DUAL_SOURCE_DRAW_BUFFERS and index is greater than or equal to one.
  • GL_INVALID_VALUE is generated if index is greater than one.
  • GL_INVALID_OPERATION is generated if name starts with the reserved gl_ prefix. (told you πŸ™ˆ)
  • GL_INVALID_OPERATION is generated if program is not the name of a program object.
fr fr, those GL_INVALID_VALUE ones will pop off if you're not careful with your numbers. vibe check your constants before you call her.

πŸ‘‘ ASSOCIATED GETS πŸ‘‘

  • glGetFragDataLocation() β€” with a valid program object and the name of a user-defined varying out variable
  • glGetFragDataIndex() β€” with a valid program object and the name of a user-defined varying out variable

🌸 VERSION SUPPORT 🌸

the original gave us a whole table (and we don't do tables here, so here's the same tea in list form β˜•). glBindFragDataLocationIndexed is:

  • not supported in OpenGL 2.0 β€” -
  • not supported in OpenGL 2.1 β€” -
  • not supported in OpenGL 3.0 β€” -
  • not supported in OpenGL 3.1 β€” -
  • supported in OpenGL 3.2 β€” βœ”
  • supported in OpenGL 3.3 β€” βœ”
  • supported in OpenGL 4.0 β€” βœ”
  • supported in OpenGL 4.1 β€” βœ”
  • supported in OpenGL 4.2 β€” βœ”
  • supported in OpenGL 4.3 β€” βœ”
  • supported in OpenGL 4.4 β€” βœ”
  • supported in OpenGL 4.5 β€” βœ”

so basically she showed up in 3.2 and has been iconic ever since ⭐


🌈 SEE ALSO 🌈

glCreateProgram(), glLinkProgram(), glGetFragDataLocation(), glGetFragDataIndex(), glBindFragDataLocation() β€” go read those too, iykyk 🫢


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 bestie, go bind those frag data locations responsibly πŸ’œ and hey β€” the source on this one is literally [FIXME: source] (yes, really 😭) and it's dated 08/09/2021, so that's the mood. mwah, bye 🧚✨

πŸ“¦ where this page comes from