GLGETPROGRAMSTAGE(3G)

πŸ’… GLGETPROGRAMSTAGE(3G) β€” bestie's guide to program stage properties πŸ’…

okay so first things first, this is the GLGETPROGRAMSTAGE(3G) page, from that manual we're just gonna call [FIXME: manual] for now (the placeholder is doing main character energy, we love that for it). sit down, grab a matcha, we're talking about glGetProgramStage β€” it retrieves properties of a program object corresponding to a specified shader stage. yes, that's a mouthful, but it's giving iconic and you're gonna get it. πŸŽ€


✨ NAME ✨

glGetProgramStage β€” retrieve properties of a program object corresponding to a specified shader stage. literally what it says on the tin, no cap. πŸ’–


🌸 C SPECIFICATION 🌸

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

copy that exactly bestie, every character matters. πŸ”₯


πŸ¦‹ PARAMETERS πŸ¦‹

  • program β€” the name of the program that contains the shader stage you're being nosy about. that's the tea right there.
  • shadertype β€” which shader stage we're querying the subroutine parameter from. it's gotta be one of these, no substitutions allowed:
    • GL_VERTEX_SHADER
    • GL_TESS_CONTROL_SHADER
    • GL_TESS_EVALUATION_SHADER
    • GL_GEOMETRY_SHADER
    • GL_FRAGMENT_SHADER
  • pname β€” the parameter of the shader you wanna query. this one also has a strict guest list, pname must be one of:
    • GL_ACTIVE_SUBROUTINE_UNIFORMS
    • GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS
    • GL_ACTIVE_SUBROUTINES
    • GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH
    • GL_ACTIVE_SUBROUTINE_MAX_LENGTH
  • values β€” the address of a variable where the queried value (or values) get dropped off. like a lil delivery slot, but for numbers. πŸ“¦

πŸ’œ DESCRIPTION πŸ’œ

so glGetProgramStage queries a parameter of a shader stage attached to a program object. program holds the name of the program the shader is attached to. shadertype says which stage we're querying from. pname says which parameter we want. and the value or values of that parameter come back in the variable whose address you handed over in values. slay. ✨

here's the breakdown of what comes back depending on pname, and this part is important so pay attention bestie:

  • if pname is GL_ACTIVE_SUBROUTINE_UNIFORMS, you get the number of active subroutine variables in the stage, in values.
  • if pname is GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, you get the number of active subroutine variable locations in the stage, in values.
  • if pname is GL_ACTIVE_SUBROUTINES, you get the number of active subroutines in the stage, in values.
  • if pname is GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH, you get the length of the longest subroutine uniform for the stage, in values.
  • if pname is GL_ACTIVE_SUBROUTINE_MAX_LENGTH, you get the length of the longest subroutine name for the stage, in values. and heads up: the returned name length includes space for the null-terminator. don't forget the null-terminator's whole existence, it's doing its job. 🫢

and one more thing β€” if there's no shader present of type shadertype, the returned value will be consistent with a shader containing no subroutines or subroutine uniforms. so it's not broken, it's just empty, and that's valid. πŸ’€


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM is generated if shadertype or pname is not one of the accepted values. read the lists above, bestie, the lists are the moment. 😭
  • GL_INVALID_VALUE is generated if program is not the name of an existing program object. like if you're querying a program that doesn't exist. tragic. not it.

πŸ‘‘ VERSION SUPPORT πŸ‘‘

the original page has a whole giant box-art chart here, and since we're keeping every last detail, here it is in list form so nothing gets lost. the function is glGetProgramStageiv (that's the "Function / Feature Name" row) and it breaks down across the OpenGL versions like this:

  • 2.0 β€” - (nope, not supported)
  • 2.1 β€” - (still nope)
  • 3.0 β€” -
  • 3.1 β€” -
  • 3.2 β€” -
  • 3.3 β€” -
  • 4.0 β€” βœ” (there it is πŸ’–)
  • 4.1 β€” βœ”
  • 4.2 β€” βœ”
  • 4.3 β€” βœ”
  • 4.4 β€” βœ”
  • 4.5 β€” βœ”

so like... glGetProgramStageiv shows up at 4.0 and stays booked and busy through 4.5. before that? ghost town. πŸ‘»


🌈 SEE ALSO 🌈

  • glGetProgram()

that's the one, go read it, 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/.

and, because the original says it twice and we do not skip details:

Copyright Β© 2010-2014 Khronos Group.


fr fr that's the whole page, no notes. the legal girlies said it twice and we respect it. πŸ’…

okay bye bestie, this came from [FIXME: source] and it's dated 08/09/2021 β€” and yes it's still GLGETPROGRAMSTAGE(3G), love that consistency for us. mwah. πŸ“πŸ’–

πŸ“¦ where this page comes from