glGetActiveUniformsiv.3G - Man Page

Returns information about several active uniform variables for the specified program object

C Specification

void glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);

Parameters

program

Specifies the program object to be queried.

uniformCount

Specifies both the number of elements in the array of indices uniformIndices and the number of parameters written to params upon successful return.

uniformIndices

Specifies the address of an array of uniformCount integers containing the indices of uniforms within program whose parameter pname should be queried.

pname

Specifies the property of each uniform in uniformIndices that should be written into the corresponding element of params.

params

Specifies the address of an array of uniformCount integers which are to receive the value of pname for each uniform in uniformIndices.

Description

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. If an error is generated, nothing is written into params.

If pname is GL_UNIFORM_TYPE, then an array identifying the types of uniforms specified by the corresponding array of uniformIndices is returned. The returned types can be any of the values from the following table:

Returned Symbolic ContantShader Uniform Type
GL_FLOATfloat
GL_FLOAT_VEC2vec2
GL_FLOAT_VEC3vec3
GL_FLOAT_VEC4vec4
GL_DOUBLEdouble
GL_DOUBLE_VEC2dvec2
GL_DOUBLE_VEC3dvec3
GL_DOUBLE_VEC4dvec4
GL_INTint
GL_INT_VEC2ivec2
GL_INT_VEC3ivec3
GL_INT_VEC4ivec4
GL_UNSIGNED_INTunsigned int
GL_UNSIGNED_INT_VEC2uvec2
GL_UNSIGNED_INT_VEC3uvec3
GL_UNSIGNED_INT_VEC4uvec4
GL_BOOLbool
GL_BOOL_VEC2bvec2
GL_BOOL_VEC3bvec3
GL_BOOL_VEC4bvec4
GL_FLOAT_MAT2mat2
GL_FLOAT_MAT3mat3
GL_FLOAT_MAT4mat4
GL_FLOAT_MAT2x3mat2x3
GL_FLOAT_MAT2x4mat2x4
GL_FLOAT_MAT3x2mat3x2
GL_FLOAT_MAT3x4mat3x4
GL_FLOAT_MAT4x2mat4x2
GL_FLOAT_MAT4x3mat4x3
GL_DOUBLE_MAT2dmat2
GL_DOUBLE_MAT3dmat3
GL_DOUBLE_MAT4dmat4
GL_DOUBLE_MAT2x3dmat2x3
GL_DOUBLE_MAT2x4dmat2x4
GL_DOUBLE_MAT3x2dmat3x2
GL_DOUBLE_MAT3x4dmat3x4
GL_DOUBLE_MAT4x2dmat4x2
GL_DOUBLE_MAT4x3dmat4x3
GL_SAMPLER_1Dsampler1D
GL_SAMPLER_2Dsampler2D
GL_SAMPLER_3Dsampler3D
GL_SAMPLER_CUBEsamplerCube
GL_SAMPLER_1D_SHADOWsampler1DShadow
GL_SAMPLER_2D_SHADOWsampler2DShadow
GL_SAMPLER_1D_ARRAYsampler1DArray
GL_SAMPLER_2D_ARRAYsampler2DArray
GL_SAMPLER_1D_ARRAY_SHADOWsampler1DArrayShadow
GL_SAMPLER_2D_ARRAY_SHADOWsampler2DArrayShadow
GL_SAMPLER_2D_MULTISAMPLEsampler2DMS
GL_SAMPLER_2D_MULTISAMPLE_ARRAYsampler2DMSArray
GL_SAMPLER_CUBE_SHADOWsamplerCubeShadow
GL_SAMPLER_BUFFERsamplerBuffer
GL_SAMPLER_2D_RECTsampler2DRect
GL_SAMPLER_2D_RECT_SHADOWsampler2DRectShadow
GL_INT_SAMPLER_1Disampler1D
GL_INT_SAMPLER_2Disampler2D
GL_INT_SAMPLER_3Disampler3D
GL_INT_SAMPLER_CUBEisamplerCube
GL_INT_SAMPLER_1D_ARRAYisampler1DArray
GL_INT_SAMPLER_2D_ARRAYisampler2DArray
GL_INT_SAMPLER_2D_MULTISAMPLEisampler2DMS
GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAYisampler2DMSArray
GL_INT_SAMPLER_BUFFERisamplerBuffer
GL_INT_SAMPLER_2D_RECTisampler2DRect
GL_UNSIGNED_INT_SAMPLER_1Dusampler1D
GL_UNSIGNED_INT_SAMPLER_2Dusampler2D
GL_UNSIGNED_INT_SAMPLER_3Dusampler3D
GL_UNSIGNED_INT_SAMPLER_CUBEusamplerCube
GL_UNSIGNED_INT_SAMPLER_1D_ARRAYusampler2DArray
GL_UNSIGNED_INT_SAMPLER_2D_ARRAYusampler2DArray
GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLEusampler2DMS
GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAYusampler2DMSArray
GL_UNSIGNED_INT_SAMPLER_BUFFERusamplerBuffer
GL_UNSIGNED_INT_SAMPLER_2D_RECTusampler2DRect

If pname is GL_UNIFORM_SIZE, then an array identifying the size of the uniforms specified by the corresponding array of uniformIndices is returned. The sizes returned are in units of the type returned by a query of GL_UNIFORM_TYPE. For active uniforms that are arrays, the size is the number of active elements in the array; for all other uniforms, the size is one.

If pname is GL_UNIFORM_NAME_LENGTH, then an array identifying the length, including the terminating null character, of the uniform name strings specified by the corresponding array of uniformIndices is returned.

If pname is GL_UNIFORM_BLOCK_INDEX, then an array identifying the uniform block index of each of the uniforms specified by the corresponding array of uniformIndices is returned. The uniform block index of a uniform associated with the default uniform block is -1.

If pname is GL_UNIFORM_OFFSET, then an array of uniform buffer offsets is returned. For uniforms in a named uniform block, the returned value will be 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 will be its offset relative to the beginning of its active atomic counter buffer. For all other uniforms, -1 will be returned.

If pname is GL_UNIFORM_ARRAY_STRIDE, then an array identifying the stride between elements of each of the uniforms specified by the corresponding array of uniformIndices is returned. 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 -1 will be returned.

If pname is GL_UNIFORM_MATRIX_STRIDE, then 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 of uniformIndices is returned. The matrix stride of a uniform associated with the default uniform block is -1. Note that this information only makes sense for uniforms that are matrices. For uniforms that are not matrices, but are declared in a named uniform block, a matrix stride of zero is returned.

If pname is GL_UNIFORM_IS_ROW_MAJOR, then an array identifying whether each of the uniforms specified by the corresponding array of uniformIndices is a row-major matrix or not is returned. A value of one indicates a row-major matrix, and a value of zero indicates a column-major matrix, a matrix in the default uniform block, or a non-matrix.

If pname is GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX, then an array identifying the active atomic counter buffer index of each of the uniforms specified by the corresponding array of uniformIndices is returned. For uniforms other than atomic counters, the returned buffer index is -1. The returned indices may be passed to glGetActiveAtomicCounterBufferiv() to query the properties of the associated buffer, and not necessarily the binding point specified in the uniform declaration.

Notes

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.

GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX is only accepted by pname if the GL version is 4.2 or higher.

Errors

GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.

GL_INVALID_OPERATION is generated if program is not a program object.

GL_INVALID_VALUE is generated if uniformCount is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.

GL_INVALID_ENUM is generated if pname is not an accepted token.

Associated Gets

glGet() with argument GL_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, or GL_MAX_COMBINED_UNIFORM_COMPONENTS.

glGetProgram() with argument GL_ACTIVE_UNIFORMS or GL_ACTIVE_UNIFORM_MAX_LENGTH.

glIsProgram()

Version Support

OpenGL Version
Function / Feature Name2.02.13.03.13.23.34.04.14.24.34.44.5
glGetActiveUniformsiv---

See Also

glGetUniform(), glGetActiveUniform(), glGetUniformLocation(), glLinkProgram(), glUniform(), glUseProgram()

Info

07/18/2024