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 withcolorNumberβ 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 tonameβ 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_VALUEis generated if colorNumber is greater than or equal toGL_MAX_DRAW_BUFFERS.GL_INVALID_VALUEis generated if colorNumber is greater than or equal toGL_MAX_DUAL_SOURCE_DRAW_BUFFERSand index is greater than or equal to one.GL_INVALID_VALUEis generated if index is greater than one.GL_INVALID_OPERATIONis generated if name starts with the reservedgl_prefix. (told you π)GL_INVALID_OPERATIONis 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 variableglGetFragDataIndex()β 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 π
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
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms