GLGETSUBROUTINEINDEX(3G)

πŸ’… GLGETSUBROUTINEINDEX β€” it's giving 3G, bestie

okay so real talk, this one is from the 3G manual section (that's the OpenGL family of manpages, if you didn't know, and now you do 🫢) and it's genuinely such a vibe once you get what it's doing. let's get into it.


✨ NAME ✨

glGetSubroutineIndex β€” grab the index of a subroutine uniform, for a specific shader stage, inside a program πŸ”₯


πŸŽ€ C SPECIFICATION πŸŽ€

GLuint glGetSubroutineIndex(GLuint program, GLenum shadertype,
                            const GLchar *name);

like, look at it. three args. so clean. so iconic. πŸ‘‘


πŸ¦‹ PARAMETERS πŸ¦‹

  • program β€” the name of the program that's holding your shader stage. this is your "which program tho" answer, bestie.
  • shadertype β€” the shader stage you're querying for a subroutine uniform index. no cap, shadertype has to be one of these five, periodt:
    • GL_VERTEX_SHADER
    • GL_TESS_CONTROL_SHADER
    • GL_TESS_EVALUATION_SHADER
    • GL_GEOMETRY_SHADER
    • GL_FRAGMENT_SHADER
  • name β€” the name of the subroutine uniform whose index you're asking about. yep. that's the whole thing. πŸ“

🌸 DESCRIPTION 🌸

so glGetSubroutineIndex returns the index of a subroutine uniform within a shader stage that's attached to a program object. three bits of lore here:

  • program holds the name of the program your shader is attached to.
  • shadertype says which stage you're querying the shader subroutine index from.
  • name holds the null-terminated name of the subroutine uniform you're querying. πŸ“›

now here's the tea β˜• β€” if name is not the name of a subroutine uniform in that shader stage, you get GL_INVALID_INDEX back, but no error is generated. like, it just quietly hands you the invalid index and moves on. no drama, no error. πŸ’€

but if name is the name of a subroutine uniform in that shader stage, you get a value between zero and the value of GL_ACTIVE_SUBROUTINES minus one. and the way subroutine indices work: they're assigned using consecutive integers, ranging from zero up to the value of GL_ACTIVE_SUBROUTINES minus one, for that shader stage. so like, no gaps, no weird jumps, just 0, 1, 2, … slay. ✨


πŸ”₯ ERRORS πŸ”₯

  • GL_INVALID_ENUM is generated if shadertype or pname is not one of the accepted values. (yes bestie, it literally says pname β€” there's no pname in this function's signature, but that's what the page says and I'm not about to gaslight the manpage πŸ™ˆ)
  • GL_INVALID_VALUE is generated if program is not the name of an existing program object. so, like, don't pass a fake program name and expect good things. 😭

πŸ‘‘ VERSION SUPPORT πŸ‘‘

here's the whole chart, kept exactly as the page has it, because I would never do you dirty like that:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      β”‚                OpenGL Version                                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€
β”‚ Function             β”‚ 2.0 β”‚ 2.1 β”‚ 3.0 β”‚ 3.1 β”‚ 3.2 β”‚ 3.3 β”‚ 4.0 β”‚ 4.1 β”‚ 4.2 β”‚ 4.3 β”‚ 4.4 β”‚ 4.5 β”‚
β”‚ /                    β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚
β”‚ Feature              β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚
β”‚ Name                 β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€
β”‚ glGetSubroutineIndex β”‚  -  β”‚  -  β”‚  -  β”‚  -  β”‚  -  β”‚  -  β”‚  βœ”  β”‚  βœ”  β”‚  βœ”  β”‚  βœ”  β”‚  βœ”  β”‚  βœ”  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜

tl;dr: - all the way from 2.0 through 3.3, then βœ” from 4.0 on up to 4.5. she arrived in 4.0 and she's been booked and busy ever since. πŸ’…


🌈 SEE ALSO 🌈

go read these next, bestie, they're the friend group:

  • glGetProgram()
  • glGetActiveSubroutineUniform()
  • glGetActiveSubroutineUniformName()

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!! 🧚 this one was source [FIXME: source], dated 08/09/2021, and it lives in the 3G manual β€” so like, cite her correctly when you talk about her. mwah, ily, go write some subroutines πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from