GLGETPROGRAMRESOURCE(3G)

✨ GLGETPROGRAMRESOURCE(3G) ✨

okay bestie, welcome to the 3G manual page for glGetProgramResourceLocation β€” yes the whole title is a mouthful, we're gonna get through it together πŸ’–


🌸 NAME 🌸

glGetProgramResourceLocation β€” query the location of a named resource within a program. that's it, that's the vibe check πŸ‘‘


πŸŽ€ C SPECIFICATION πŸŽ€

GLint glGetProgramResourceLocation(GLuint program,
                                   GLenum programInterface,
                                   const char * name);

look at her. three args, one GLint coming back. iconic. πŸ’…


πŸ¦‹ PARAMETERS πŸ¦‹

  • program β€” the name of a program object whose resources you wanna query. like, which program are we snooping in, bestie? πŸ”
  • programInterface β€” a token identifying the interface within program that contains the resource named name. it's giving "which section of the program" energy.
  • name β€” the name of the resource to query the location of. literally just tell it what you're looking for fr fr.

🌈 DESCRIPTION 🌈

so glGetProgramResourceLocation returns the location assigned to the variable named name in interface programInterface of program object program. got it? good. πŸ’œ

program must be the name of a program that has been linked successfully. no half-baked programs, we don't do that here πŸ™ˆ

and programInterface has to be one of these ten tokens, no substitutions:

  • GL_UNIFORM
  • GL_PROGRAM_INPUT
  • GL_PROGRAM_OUTPUT
  • GL_VERTEX_SUBROUTINE_UNIFORM
  • GL_TESS_CONTROL_SUBROUTINE_UNIFORM
  • GL_TESS_EVALUATION_SUBROUTINE_UNIFORM
  • GL_GEOMETRY_SUBROUTINE_UNIFORM
  • GL_FRAGMENT_SUBROUTINE_UNIFORM
  • GL_COMPUTE_SUBROUTINE_UNIFORM
  • GL_TRANSFORM_FEEDBACK_BUFFER

slay. periodt. ✨

the value -1 will be returned if an error occurs, 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. so -1 is basically the "nope, not found, not valid, or something went wrong" of return values πŸ’€

the locations returned by these commands are the same locations returned when querying the GL_LOCATION and GL_LOCATION_INDEX resource properties. same numbers, different door πŸšͺ


🧚 when does a string actually match an active variable?

a string you hand to glGetProgramResourceLocation is considered to match an active variable if:

  • 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. yes that's a whole sentence, read it twice, it's fine, i believe in you 🫢

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 one gets the crown πŸ‘‘


πŸ’… ERRORS πŸ’…

  • GL_INVALID_VALUE is generated if program is not the name of an existing program object. like, that program does not exist, bestie πŸ’€
  • GL_INVALID_ENUM is generated if programInterface is not one of the accepted interface types. read the list again, it's up there ⬆️
  • GL_INVALID_OPERATION is generated if program has not been linked successfully. link it first omg πŸ”₯

⭐ VERSION SUPPORT ⭐

the function in question is glGetProgramResourceLocation, and the feature-name column situation is: just her πŸ’β€β™€οΈ

here's the OpenGL version tea 🍡:

  • 2.0 β€” - (nope)
  • 2.1 β€” - (still nope)
  • 3.0 β€” - (nope)
  • 3.1 β€” - (nope)
  • 3.2 β€” - (nope)
  • 3.3 β€” - (nope)
  • 4.0 β€” - (nope)
  • 4.1 β€” - (nope)
  • 4.2 β€” - (nope)
  • 4.3 β€” βœ” (oh she's here!!) πŸŽ‰
  • 4.4 β€” βœ” (yes)
  • 4.5 β€” βœ” (yes)

so she showed up in 4.3 and stayed. main character energy from 4.3 onward πŸ‘‘πŸ’–


🌸 SEE ALSO 🌸

go read these too, they're all in the family:

  • glGetProgramResourceName()
  • glGetProgramResourceIndex()
  • glGetProgramResource()
  • glGetProgramResourceLocationIndex()

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/.

and again, because she said it twice and we respect the repetition:

Copyright Β© 2013-2014 Khronos Group


okay that's the whole page bestie, you ate that πŸ“βœ¨ one lil sign-off before you go: this was pulled from [FIXME: source] (yes, the source field is literally still a FIXME and honestly? relatable), dated 08/09/2021, and it lives under the GLGETPROGRAMRESOURCE(3G) header. now go query some resource locations, i'm obsessed with you πŸ’œπŸŽ€

πŸ“¦ where this page comes from