GLGETACTIVESUBROUTIN(3G)

πŸ’… NAME πŸ’…

glGetActiveSubroutineUniform β€” bestie, this is how you query a property of an active shader subroutine uniform ✨ (yes, the page header says GLGETACTIVESUBROUTIN(3G), section 3G, so you know exactly where you are 🫢)


✨ C SPECIFICATION ✨

void glGetActiveSubroutineUniformiv(GLuint program, GLenum shadertype,
                                    GLuint index, GLenum pname,
                                    GLint *values);

πŸŽ€ PARAMETERS πŸŽ€

  • program β€” the name of the program that's holding your subroutine, like the group chat that contains the vibe πŸ’–
  • shadertype β€” which shader stage you're querying the subroutine parameter from, and it literally must be one of GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER, or GL_FRAGMENT_SHADER. no substitutions, no "close enough" πŸ™…β€β™€οΈ
  • index β€” the index of the shader subroutine uniform. it's giving "which one of these is it" energy πŸ”₯
  • pname β€” the parameter of the shader subroutine uniform you wanna look up, and it must be GL_NUM_COMPATIBLE_SUBROUTINES, GL_COMPATIBLE_SUBROUTINES, GL_UNIFORM_SIZE, or GL_UNIFORM_NAME_LENGTH ✨
  • values β€” the address of a thing into which the queried value or values get placed. it's the drop-off spot, the little mailbox where your answer lands πŸ“¬

🌸 DESCRIPTION 🌸

So glGetActiveSubroutineUniform queries a parameter of an active shader subroutine uniform β€” that's the whole assignment, that's the task πŸ’…

program contains the name of the program containing the uniform. shadertype specifies the stage for which the uniform location, given by index, is valid. And index must be between zero and the value of GL_ACTIVE_SUBROUTINE_UNIFORMS minus one for the shader stage. no cap, that's the range, don't push it πŸ™ˆ

Now, what you get back depends on pname, so let's break it down bestie:

  • If pname is GL_NUM_COMPATIBLE_SUBROUTINES, a single integer is returned in values, indicating the number of subroutines that can be assigned to the uniform. just a count, a little headcount πŸŽ€
  • If pname is GL_COMPATIBLE_SUBROUTINES, an array of integers is returned in values, and each integer specifies the index of an active subroutine that can be assigned to the selected subroutine uniform. The number of integers returned is the same as the value returned for GL_NUM_COMPATIBLE_SUBROUTINES β€” so like, they match, they're in sync, iconic πŸ”₯
  • If pname is GL_UNIFORM_SIZE, a single integer is returned in values. If the selected subroutine uniform is an array, the declared size of the array is returned; otherwise, one is returned. simple as that ✨
  • If pname is GL_UNIFORM_NAME_LENGTH, a single integer specifying the length of the subroutine uniform name (including the terminating null character) is returned in values. yes, the null character counts, she's part of the family πŸ’–

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM is generated if shadertype or pname is not one of the accepted values. read the list, bestie 😭
  • GL_INVALID_VALUE is generated if index is greater than or equal to the value of GL_ACTIVE_SUBROUTINES. out of bounds = instant no 🌈
  • GL_INVALID_VALUE is generated if program is not the name of an existing program object. like, it has to exist, you can't just make one up 🫢

⭐ ASSOCIATED GETS ⭐

glGetProgramStage() with argument GL_ACTIVE_SUBROUTINE_UNIFORMS β€” that's the side quest that goes with this one 🧚


πŸ‘‘ VERSION SUPPORT πŸ‘‘

The table in the original is very "spreadsheet main character energy", so here it is as a glow-up ✨ β€” same facts, same numbers, no table:

Function / Feature Name: glGetActiveSubroutineUniformiv

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

So she shows up at 4.0 and stays slaying through 4.5. periodt πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹

  • glGetSubroutineIndex()
  • glGetActiveSubroutineUniformName()
  • glGetProgramStage()

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, you ate that πŸ“ before you go: this gem came from the [FIXME: source] era, dated 08/09/2021, and it's filed under GLGETACTIVESUBROUTIN(3G) β€” mwah, go write some shaders bestie πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from