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,shadertypehas to be one of these five, periodt:GL_VERTEX_SHADERGL_TESS_CONTROL_SHADERGL_TESS_EVALUATION_SHADERGL_GEOMETRY_SHADERGL_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:
programholds the name of the program your shader is attached to.shadertypesays which stage you're querying the shader subroutine index from.nameholds 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_ENUMis generated ifshadertypeorpnameis not one of the accepted values. (yes bestie, it literally sayspnameβ there's nopnamein this function's signature, but that's what the page says and I'm not about to gaslight the manpage π)GL_INVALID_VALUEis generated ifprogramis 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 π
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
- 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