GLGETPROGRAMRESOURCE(3G)
π
GLGETPROGRAMRESOURCE(3G) β like, the glGetProgramResourceLocationIndex of it all
okay bestie, so this is a page out of the 3G manual (yes, the OpenGL one) and it's literally about asking your shader program "hey girl, where does this variable live in your fragment color output?" π buckle up.
β¨ NAME β¨
glGetProgramResourceLocationIndex β query the fragment color index of a named variable within a program. that's it, that's the whole vibe π¦
πΈ C SPECIFICATION πΈ
GLint glGetProgramResourceLocationIndex(GLuint program,
GLenum programInterface,
const char * name);
π PARAMETERS π
programβ the name of a program object whose resources you wanna query. like, which program are we snooping through πprogramInterfaceβ a token identifying the interface withinprogramthat contains the resource namedname. the little doorway you're peeking through πͺnameβ the name of the resource whose location you're asking about. the actual variable, by name, periodt.
π DESCRIPTION π
so glGetProgramResourceLocationIndex returns the fragment color index assigned to the variable named name in interface programInterface of program object program. π«
but bestie, the rules: program must be the name of a program that has been linked successfully. no linked program, no answers, i don't make the rules. and programInterface must be GL_PROGRAM_OUTPUT. that's the only accepted one here, no cap.
the value -1 gets returned if an error happens, if name does not identify an active variable on programInterface, or if name identifies an active variable that does not have a valid location assigned, as described above. sad but true π
the locations returned by these commands are the same locations returned when querying the GL_LOCATION and GL_LOCATION_INDEX resource properties. consistency, we love to see it π
π so when does a string actually match an active variable?
a string you hand to glGetProgramResourceLocationIndex is considered to match an active variable if β and only if, iykyk:
- the string exactly matches the name of the active variable π―
- if the string identifies the base name of an active array, where the string would exactly match the name of the variable if the suffix
"[0]"were appended to the string π§ - if the string identifies an active element of the array, where the string ends with the concatenation of the
"["character, an integer with no"+"sign, extra leading zeroes, or whitespace identifying an array element, and the"]"character, the integer is less than the number of active elements of the array variable, and where the string would exactly match the enumerated name of the array if the decimal integer were replaced with zero. (i know. read it twice. it's giving very specific, and that's on purpose π)
any other string is considered not to identify an active variable. sorry babe. π
if the string specifies an element of an array variable, glGetProgramResourceLocation returns the location assigned to that element. and if it specifies the base name of an array, it identifies the resources associated with the first element of the array. first come, first served β¨
β οΈ heads up: yes, that second-to-last paragraph really does say glGetProgramResourceLocation β that's how it's written on the page, so i'm keeping it exactly. not my typo to fix, bestie π«Ά
π ERRORS π
GL_INVALID_VALUEis generated ifprogramis not the name of an existing program object. (it's not a real one, girl π)GL_INVALID_ENUMis generated ifprogramInterfaceis not one of the accepted interface types. wrong token, wrong door π«GL_INVALID_OPERATIONis generated ifprogramhas not been linked successfully. link it first, then come talk to me π€
π VERSION SUPPORT π
here's the whole roster, 2.0 all the way to 4.5, and the glGetProgramResourceLocationIndex row goes like this:
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 basically: nothing, nothing, nothing, nothingβ¦ and then 4.3 shows up and slays π₯π it's a 4.3+ girlie, fr fr.
π¦ SEE ALSO π¦
glGetProgramResourceName()glGetProgramResourceIndex()glGetProgramResource()glGetProgramResourceLocationIndex()(yes, it references itself. main character energy, honestly π)
π COPYRIGHT π
Copyright Β© 2013-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 (again, bestie) π
Copyright Β© 2013-2014 Khronos Group
okay that's the whole page, you ate that π
and for the cute little sign-off β the footer says the source is [FIXME: source], dated 08/09/2021, closing out under the GLGETPROGRAMRESOURCE(3G) banner. stan a slightly unfinished FIXME, honestly. go query those locations, bestie πΈβ¨π«Ά
π¦ 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