GLGETACTIVESUBROUTIN(3G)
π GLGETACTIVESUBROUTIN(3G) β bestie, let's learn this one
okay so this is a page from the 3G manual (yep, the OpenGL one), and it's all about glGetActiveSubroutineUniformName. Which, real talk, is a whole mouthful β but it's genuinely just "tell me the name of this shader subroutine uniform, please." Let's get into it π
β¨ NAME β¨
glGetActiveSubroutineUniformName β query the name of an active shader subroutine uniform.
Like. That's the whole vibe. You ask, it tells you the name. Iconic behaviour honestly π
πΈ C SPECIFICATION πΈ
void glGetActiveSubroutineUniformName(GLuint program, GLenum shadertype,
GLuint index, GLsizei bufSize,
GLsizei *length, GLchar *name);
Six arguments, no cap. Don't worry, we're going through every single one π
π¦ PARAMETERS π¦
programβ the name of the program that's holding the subroutine. Like, which program are we even talking about, bestie.shadertypeβ the shader stage you're querying the subroutine parameter from. It must be one ofGL_VERTEX_SHADER,GL_TESS_CONTROL_SHADER,GL_TESS_EVALUATION_SHADER,GL_GEOMETRY_SHADER, orGL_FRAGMENT_SHADER. Those five. No substitutions, no "close enough" πindexβ the index of the shader subroutine uniform. Your little pointer to which one you want.bufSizeβ the size of the buffer whose address you're handing over inname. Basically: how much room are you giving it to write into.lengthβ the address of a variable where it writes back the number of characters that got copied intoname. It's the "how much did you actually use" receipt π§Ύnameβ the address of a buffer that receives the name of the specified shader subroutine uniform. This is where the actual string lands, bestie.
π DESCRIPTION π
glGetActiveSubroutineUniformName retrieves the name of an active shader subroutine uniform β literally what it says on the tin.
So: 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. Off-by-one girlies, be careful, that's a real boundary π
The uniform name comes back as a null-terminated string in name. The actual number of characters written into name β excluding the null terminator β is returned in length. And if length is NULL, no length is returned at all. Nothing. Zero info. That's the deal π«Ά
The maximum number of characters that may be written into name, including the null terminator, is specified by bufSize.
And if you're wondering how big to make your buffer? The length of the longest subroutine uniform name in program and shadertype is given by the value of GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH, which you can query with glGetProgramStage(). Chef's kiss, that's your sizing hookup β¨
π₯ ERRORS π₯
GL_INVALID_ENUMis generated ifshadertypeorpnameis not one of the accepted values. (yes, it sayspnameβ that's what the page says, we don't ask questions π)GL_INVALID_VALUEis generated ifindexis greater than or equal to the value ofGL_ACTIVE_SUBROUTINE_UNIFORMS.GL_INVALID_VALUEis generated ifprogramis not the name of an existing program object.
bestie. if you're getting one of these, something you passed in was not it. go check your values before you come for the driver π
π ASSOCIATED GETS π
glGetProgramStage()with argumentGL_ACTIVE_SUBROUTINE_UNIFORMS
β VERSION SUPPORT β
The original gives you a big grid across OpenGL versions, so here's the tea in list form β the fmt is Function / Feature Name, and the function is glGetActiveSubroutineUniformName:
2.0β nope β2.1β nope β3.0β nope β3.1β nope β3.2β nope β3.3β nope β4.0β yes β4.1β yes β4.2β yes β4.3β yes β4.4β yes β4.5β yes β
So like... it really shows up in 4.0 and everything after. Before that? not me being unavailable π
π SEE ALSO π
glGetSubroutineIndex()glGetActiveSubroutineUniform()glGetProgramStage()
go read those next, they're the friend group π«Ά
π 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.
and that's the page, bestie πΈ it came from [FIXME: source] and it's dated 08/09/2021 β so go forth and query those subroutine uniform names, you absolute main character ππ¦
π¦ 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