GLGETACTIVEUNIFORMSI(3G)
π glGetActiveUniformsiv(3G) π
okay so bestie, welcome to glGetActiveUniformsiv β yes that's a mouthful, no I will not be pronouncing it out loud β and it lives in the [FIXME: manual] manual, section 3G. iconic. let's get into it π«Ά
β¨ NAME β¨
glGetActiveUniformsiv β returns information about several active uniform variables for the specified program object. that's the whole vibe. it's giving "i have questions and i need answers about my uniforms" π
πΈ C SPECIFICATION πΈ
like, literally this is the function signature, copy it exactly, do not touch it, she is perfect:
void glGetActiveUniformsiv(GLuint program, GLsizei uniformCount,
const GLuint *uniformIndices, GLenum pname,
GLint *params);
π PARAMETERS π
okay so now we meet the cast of characters. five of them. all important. no skips π
programβ specifies the program object to be queried. like, which program are we snooping on. that's the one π΅οΈββοΈuniformCountβ specifies both the number of elements in the array of indicesuniformIndicesand the number of parameters written toparamsupon successful return. so she's doing double duty, highkey a multi-hyphenate π one number, two jobs, we love a main character β¨uniformIndicesβ specifies the address of an array ofuniformCountintegers containing the indices of uniforms withinprogramwhose parameterpnameshould be queried. so it's the lil guest list of which uniforms we're asking about πpnameβ specifies the property of each uniform inuniformIndicesthat should be written into the corresponding element ofparams. like, what do you wanna know about them. the property in question ππ¦paramsβ specifies the address of an array ofuniformCountintegers which are to receive the value ofpnamefor each uniform inuniformIndices. this is the answer sheet, the receipts, where the tea gets written down π
π DESCRIPTION π
so here's the whole situation, bestie:
glGetActiveUniformsiv queries the value of the parameter named pname for each of the uniforms within program whose indices are specified in the array of uniformCount unsigned integers uniformIndices.
upon success, the value of the parameter for each uniform is written into the corresponding entry in the array whose address is given in params. one in, one out. matching entries. slay β¨
π¨ and listen β if an error is generated, nothing is written intoparams. like, nothing. zero. not a single entry. so don't go reading yourparamsarray all hopeful after an error, because she is untouched ππ
Okay so when pname is GL_UNIFORM_TYPE, you get back an array telling you the type of each uniform β one entry per element of your uniformIndices array, in the same order. It's giving very "match the answer sheet to the question sheet" energy β¨
And these are literally all the possible values it can hand back, paired with the shader type they mean:
GL_FLOATβfloatGL_FLOAT_VEC2βvec2GL_FLOAT_VEC3βvec3GL_FLOAT_VEC4βvec4GL_DOUBLEβdoubleGL_DOUBLE_VEC2βdvec2GL_DOUBLE_VEC3βdvec3GL_DOUBLE_VEC4βdvec4GL_INTβintGL_INT_VEC2βivec2GL_INT_VEC3βivec3GL_INT_VEC4βivec4GL_UNSIGNED_INTβunsigned intGL_UNSIGNED_INT_VEC2βuvec2GL_UNSIGNED_INT_VEC3βuvec3GL_UNSIGNED_INT_VEC4βuvec4GL_BOOLβboolGL_BOOL_VEC2βbvec2GL_BOOL_VEC3βbvec3GL_BOOL_VEC4βbvec4GL_FLOAT_MAT2βmat2GL_FLOAT_MAT3βmat3GL_FLOAT_MAT4βmat4GL_FLOAT_MAT2x3βmat2x3GL_FLOAT_MAT2x4βmat2x4GL_FLOAT_MAT3x2βmat3x2GL_FLOAT_MAT3x4βmat3x4GL_FLOAT_MAT4x2βmat4x2GL_FLOAT_MAT4x3βmat4x3GL_DOUBLE_MAT2βdmat2GL_DOUBLE_MAT3βdmat3GL_DOUBLE_MAT4βdmat4GL_DOUBLE_MAT2x3βdmat2x3GL_DOUBLE_MAT2x4βdmat2x4GL_DOUBLE_MAT3x2βdmat3x2GL_DOUBLE_MAT3x4βdmat3x4GL_DOUBLE_MAT4x2βdmat4x2
...still going through the type match-ups, bestie, we're in the back half now, no stopping π (each one's the GL_* enum on the left and the exact GLSL type name string it hands back on the right β character for character, no cap):
GL_DOUBLE_MAT4x3βdmat4x3GL_SAMPLER_1Dβsampler1DGL_SAMPLER_2Dβsampler2DGL_SAMPLER_3Dβsampler3DGL_SAMPLER_CUBEβsamplerCubeGL_SAMPLER_1D_SHADOWβsampler1DShadowGL_SAMPLER_2D_SHADOWβsampler2DShadowGL_SAMPLER_1D_ARRAYβsampler1DArrayGL_SAMPLER_2D_ARRAYβsampler2DArrayGL_SAMPLER_1D_ARRAY_SHADOWβsampler1DArrayShadowGL_SAMPLER_2D_ARRAY_SHADOWβsampler2DArrayShadowGL_SAMPLER_2D_MULTISAMPLEβsampler2DMSGL_SAMPLER_2D_MULTISAMPLE_ARRAYβsampler2DMSArrayGL_SAMPLER_CUBE_SHADOWβsamplerCubeShadowGL_SAMPLER_BUFFERβsamplerBufferGL_SAMPLER_2D_RECTβsampler2DRectGL_SAMPLER_2D_RECT_SHADOWβsampler2DRectShadowGL_INT_SAMPLER_1Dβisampler1DGL_INT_SAMPLER_2Dβisampler2DGL_INT_SAMPLER_3Dβisampler3DGL_INT_SAMPLER_CUBEβisamplerCubeGL_INT_SAMPLER_1D_ARRAYβisampler1DArrayGL_INT_SAMPLER_2D_ARRAYβisampler2DArrayGL_INT_SAMPLER_2D_MULTISAMPLEβisampler2DMSGL_INT_SAMPLER_2D_MULTISAMPLE_ARRAYβisampler2DMSArrayGL_INT_SAMPLER_BUFFERβisamplerBufferGL_INT_SAMPLER_2D_RECTβisampler2DRectGL_UNSIGNED_INT_SAMPLER_1Dβusampler1DGL_UNSIGNED_INT_SAMPLER_2Dβusampler2DGL_UNSIGNED_INT_SAMPLER_3Dβusampler3DGL_UNSIGNED_INT_SAMPLER_CUBEβusamplerCubeGL_UNSIGNED_INT_SAMPLER_1D_ARRAYβusampler2DArrayGL_UNSIGNED_INT_SAMPLER_2D_ARRAYβusampler2DArrayGL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLEβusampler2DMSGL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAYβusampler2DMSArrayGL_UNSIGNED_INT_SAMPLER_BUFFERβusamplerBufferGL_UNSIGNED_INT_SAMPLER_2D_RECTβusampler2DRect
π«Ά real talk, bestie: those last twousamplerlines βGL_UNSIGNED_INT_SAMPLER_1D_ARRAYβusampler2DArrayandGL_UNSIGNED_INT_SAMPLER_2D_ARRAYβusampler2DArrayβ that's literally what the page says, so I'm passing it straight to you exactly like that. Copy it verbatim, don't go "fixing" it on me. π
okay so now β GL_UNIFORM_SIZE π
If pname is GL_UNIFORM_SIZE, then what comes back is an array identifying the size of the uniforms specified by the corresponding array of uniformIndices. That array is returned, periodt.
And the sizes it returns? They're in units of the type returned by a query of GL_UNIFORM_TYPE β so like, whatever type GL_UNIFORM_TYPE just told you that uniform was, that's the unit of measurement for its size β¨.
For active uniforms that are arrays, the size is the number of active elements in the array π¦. For all other uniforms β everything that isn't one of those array situations β the size is one. One. That's it. That's the number. πββοΈ
So like, here's the tea on each pname value you can pass, bestie π β this is the part where it actually tells you what comes back:
- If
pnameisGL_UNIFORM_NAME_LENGTH, then you get back an array that tells you the length β including the terminating null character β of the uniform name strings specified by the corresponding array ofuniformIndices. β¨ - If
pnameisGL_UNIFORM_BLOCK_INDEX, then you get an array identifying the uniform block index of each of the uniforms specified by the corresponding array ofuniformIndices. And heads up: the uniform block index of a uniform that's chillin' in the default uniform block is-1. π«Ά - If
pnameisGL_UNIFORM_OFFSET, then you get an array of uniform buffer offsets. For uniforms in a named uniform block, the returned value is its offset, in basic machine units, relative to the beginning of the uniform block in the buffer object data store. For atomic counter uniforms, the returned value is its offset relative to the beginning of its active atomic counter buffer. For all other uniforms,-1is returned. π - If
pnameisGL_UNIFORM_ARRAY_STRIDE, then you get an array identifying the stride between elements of each of the uniforms specified by the corresponding array ofuniformIndices. For uniforms in named uniform blocks and for uniforms declared as atomic counters, the stride is the difference, in basic machine units, of consecutive elements in an array β or zero for uniforms not declared as an array. For all other uniforms, a stride of-1is returned. π - If
pnameisGL_UNIFORM_MATRIX_STRIDE, then you get an array identifying the stride between columns of a column-major matrix or rows of a row-major matrix, in basic machine units, of each of the uniforms specified by the corresponding array ofuniformIndices. The matrix stride of a uniform associated with the default uniform block is-1. Note that this info only makes sense for uniforms that are matrices β for uniforms that aren't matrices but are declared in a named uniform block, a matrix stride of zero is returned. no cap π§ - If
pnameisGL_UNIFORM_IS_ROW_MAJOR, then you get an array identifying whether each of the uniforms specified by the corresponding array ofuniformIndicesis a row-major matrix or not. A value of one means row-major matrix, and a value of zero means column-major matrix, a matrix in the default uniform block, or a non-matrix. literally the vibe check for matrices π - If
pnameisGL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX, then you get an array identifying the active atomic counter buffer index of each of the uniforms specified by the corresponding array ofuniformIndices. For uniforms other than atomic counters, the returned buffer index is-1. These returned indices may be passed toglGetActiveAtomicCounterBufferiv()to query the properties of the associated buffer β and not necessarily the binding point specified in the uniform declaration. iykyk π
πΈ NOTES πΈ
Ok so the double types β GL_DOUBLE, GL_DOUBLE_VEC2, GL_DOUBLE_VEC3, GL_DOUBLE_VEC4, GL_DOUBLE_MAT2, GL_DOUBLE_MAT3, GL_DOUBLE_MAT4, GL_DOUBLE_MAT2x3, GL_DOUBLE_MAT2x4, GL_DOUBLE_MAT3x2, GL_DOUBLE_MAT3x4, GL_DOUBLE_MAT4x2, and GL_DOUBLE_MAT4x3 β are only available if the GL version is 4.1 or higher. gatekept fr π
And GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX is only accepted by pname if the GL version is 4.2 or higher. β
π ERRORS π
GL_INVALID_VALUEis generated ifprogramis not a value generated by OpenGL.GL_INVALID_OPERATIONis generated ifprogramis not a program object.GL_INVALID_VALUEis generated ifuniformCountis greater than or equal to the value ofGL_ACTIVE_UNIFORMSforprogram.GL_INVALID_ENUMis generated ifpnameis not an accepted token.
bestie if you're seeing these, something's not slaying. double-check yourprogramand yourpnamebefore you spiral π
π¦ ASSOCIATED GETS π¦
glGet()with argumentGL_MAX_VERTEX_UNIFORM_COMPONENTS,GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS,GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS,GL_MAX_GEOMETRY_UNIFORM_COMPONENTS,GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, orGL_MAX_COMBINED_UNIFORM_COMPONENTS.glGetProgram()with argumentGL_ACTIVE_UNIFORMSorGL_ACTIVE_UNIFORM_MAX_LENGTH.glIsProgram()
π VERSION SUPPORT π
Ok the original had a whole table situation, but here's the same tea in list form, because we're cute like that π
glGetActiveUniformsiv across the OpenGL versions:
2.0β not supported2.1β not supported3.0β not supported3.1β supported β3.2β supported β3.3β supported β4.0β supported β4.1β supported β4.2β supported β4.3β supported β4.4β supported β4.5β supported β
so it's giving 3.1 and up only, periodt πΈ
π SEE ALSO π
glGetUniform(), glGetActiveUniform(), glGetUniformLocation(), glLinkProgram(), glUniform(), glUseProgram()
π COPYRIGHT π
Copyright Β© 2011-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 Β© 2011-2014 Khronos Group
ok that's the whole page, you made it to the end bestie, iconic behavior β¨π«Ά This lil beauty comes from [FIXME: source], dated 08/09/2021, and it lives under the name GLGETACTIVEUNIFORMSI(3G) β go forth and query those uniforms, mwah π
π
π¦ 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