GLGETSUBROUTINEUNIFO(3G)

๐Ÿ’…โœจ GLGETSUBROUTINEUNIFO(3G) โœจ๐Ÿ’…

okay so bestie, welcome to the 3G manual page, and no cap this one is a little baddie. sit down, grab a matcha ๐Ÿ“, and let's get into it.


๐ŸŒธ NAME ๐ŸŒธ

glGetSubroutineUniformLocation โ€” it literally retrieves the location of a subroutine uniform of a given shader stage within a program. that's it. that's the whole job. iconic behavior honestly ๐Ÿ‘‘


๐ŸŽ€ C SPECIFICATION ๐ŸŽ€

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

keep it verbatim bestie, don't touch the signature, she's perfect ๐Ÿ’–


๐Ÿฆ‹ PARAMETERS ๐Ÿฆ‹

  • program โ€” specifies the name of the program containing shader stage. like, which program are we even talking about, give her a name ๐Ÿซถ
  • shadertype โ€” specifies the shader stage from which to query for subroutine uniform index. and it must be one of GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER or GL_FRAGMENT_SHADER. no improvising, no freestyling, those are the options periodt ๐Ÿ’…
  • name โ€” specifies the name of the subroutine uniform whose index to query. it's giving "tell me who you're looking for" โœจ

๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

okay so glGetSubroutineUniformLocation returns the location of the subroutine uniform variable name in the shader stage of type shadertype attached to program, and its behavior is otherwise identical to glGetUniformLocation(). same energy, different function, iykyk ๐ŸŒˆ

now the important part, listen up ๐Ÿ“ข โ€” if name is not the name of a subroutine uniform in the shader stage, -1 is returned, but no error is generated. like she just shrugs and gives you a negative one, no drama, no exception, nothing ๐Ÿ˜ญ

but if name is the name of a subroutine uniform in the shader stage, a value between zero and the value of GL_ACTIVE_SUBROUTINE_LOCATIONS minus one will be returned. lowkey math but stay with me ๐Ÿงฎ

subroutine locations are assigned using consecutive integers in the range from zero to the value of GL_ACTIVE_SUBROUTINE_LOCATIONS minus one for the shader stage. and for active subroutine uniforms declared as arrays, the declared array elements are assigned consecutive locations too. consecutive, consecutive, consecutive โ€” she does not skip numbers, that's the whole vibe ๐ŸŽฏ


๐Ÿ”ฅ ERRORS ๐Ÿ”ฅ

yes bestie, things can go wrong, here's the receipts:

  • GL_INVALID_ENUM is generated if shadertype or pname is not one of the accepted values. (yes it says pname in the original, i'm just the messenger ๐Ÿ™ˆ)
  • GL_INVALID_VALUE is generated if program is not the name of an existing program object. like girl that program does not exist, stop playing ๐Ÿ’€
โš ๏ธ fr fr read these before you ship, these errors are not a cute look in a debug session.

๐Ÿ‘‘ VERSION SUPPORT ๐Ÿ‘‘

the original is a big glossy table with a Function / Feature Name column, and the feature name is literally glGetSubroutineUniformLocation. so here's the tea in list form, every single version, nothing skipped ๐Ÿซถ

  • OpenGL 2.0 โ€” - (nope)
  • OpenGL 2.1 โ€” - (nope)
  • OpenGL 3.0 โ€” - (nope)
  • OpenGL 3.1 โ€” - (nope)
  • OpenGL 3.2 โ€” - (nope)
  • OpenGL 3.3 โ€” - (nope)
  • OpenGL 4.0 โ€” โœ” (HERE SHE IS โญ)
  • OpenGL 4.1 โ€” โœ”
  • OpenGL 4.2 โ€” โœ”
  • OpenGL 4.3 โ€” โœ”
  • OpenGL 4.4 โ€” โœ”
  • OpenGL 4.5 โ€” โœ”

so like, 2.0 through 3.3 said "not today", and 4.0 through 4.5 said "main character energy" ๐Ÿ’…โœจ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

go read these next, bestie, they're all in the group chat too ๐Ÿซถ

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

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.

(both of them, bestie โ€” the original says it twice, so we say it twice, we don't skip lines in this house ๐ŸŽ€)


and that's the whole page! the source line is [FIXME: source] and the date is 08/09/2021, which honestly is a lil vintage but she ate anyway. mwah, study up, ily, bye ๐Ÿงš๐Ÿ’œ

๐Ÿ“ฆ where this page comes from