glGetActiveUniformsiv - OpenGL 4 Reference Pages

## Name

glGetActiveUniformsiv — 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 Contant | Shader Uniform Type
--- | ---
`GL_FLOAT` | `float`
`GL_FLOAT_VEC2` | `vec2`
`GL_FLOAT_VEC3` | `vec3`
`GL_FLOAT_VEC4` | `vec4`
`GL_DOUBLE` | `double`
`GL_DOUBLE_VEC2` | `dvec2`
`GL_DOUBLE_VEC3` | `dvec3`
`GL_DOUBLE_VEC4` | `dvec4`
`GL_INT` | `int`
`GL_INT_VEC2` | `ivec2`
`GL_INT_VEC3` | `ivec3`
`GL_INT_VEC4` | `ivec4`
`GL_UNSIGNED_INT` | `unsigned int`
`GL_UNSIGNED_INT_VEC2` | `uvec2`
`GL_UNSIGNED_INT_VEC3` | `uvec3`
`GL_UNSIGNED_INT_VEC4` | `uvec4`
`GL_BOOL` | `bool`
`GL_BOOL_VEC2` | `bvec2`
`GL_BOOL_VEC3` | `bvec3`
`GL_BOOL_VEC4` | `bvec4`
`GL_FLOAT_MAT2` | `mat2`
`GL_FLOAT_MAT3` | `mat3`
`GL_FLOAT_MAT4` | `mat4`
`GL_FLOAT_MAT2x3` | `mat2x3`
`GL_FLOAT_MAT2x4` | `mat2x4`
`GL_FLOAT_MAT3x2` | `mat3x2`
`GL_FLOAT_MAT3x4` | `mat3x4`
`GL_FLOAT_MAT4x2` | `mat4x2`
`GL_FLOAT_MAT4x3` | `mat4x3`
`GL_DOUBLE_MAT2` | `dmat2`
`GL_DOUBLE_MAT3` | `dmat3`
`GL_DOUBLE_MAT4` | `dmat4`
`GL_DOUBLE_MAT2x3` | `dmat2x3`
`GL_DOUBLE_MAT2x4` | `dmat2x4`
`GL_DOUBLE_MAT3x2` | `dmat3x2`
`GL_DOUBLE_MAT3x4` | `dmat3x4`
`GL_DOUBLE_MAT4x2` | `dmat4x2`
`GL_DOUBLE_MAT4x3` | `dmat4x3`
`GL_SAMPLER_1D` | `sampler1D`
`GL_SAMPLER_2D` | `sampler2D`
`GL_SAMPLER_3D` | `sampler3D`
`GL_SAMPLER_CUBE` | `samplerCube`
`GL_SAMPLER_1D_SHADOW` | `sampler1DShadow`
`GL_SAMPLER_2D_SHADOW` | `sampler2DShadow`
`GL_SAMPLER_1D_ARRAY` | `sampler1DArray`
`GL_SAMPLER_2D_ARRAY` | `sampler2DArray`
`GL_SAMPLER_1D_ARRAY_SHADOW` | `sampler1DArrayShadow`
`GL_SAMPLER_2D_ARRAY_SHADOW` | `sampler2DArrayShadow`
`GL_SAMPLER_2D_MULTISAMPLE` | `sampler2DMS`
`GL_SAMPLER_2D_MULTISAMPLE_ARRAY` | `sampler2DMSArray`
`GL_SAMPLER_CUBE_SHADOW` | `samplerCubeShadow`
`GL_SAMPLER_BUFFER` | `samplerBuffer`
`GL_SAMPLER_2D_RECT` | `sampler2DRect`
`GL_SAMPLER_2D_RECT_SHADOW` | `sampler2DRectShadow`
`GL_INT_SAMPLER_1D` | `isampler1D`
`GL_INT_SAMPLER_2D` | `isampler2D`
`GL_INT_SAMPLER_3D` | `isampler3D`
`GL_INT_SAMPLER_CUBE` | `isamplerCube`
`GL_INT_SAMPLER_1D_ARRAY` | `isampler1DArray`
`GL_INT_SAMPLER_2D_ARRAY` | `isampler2DArray`
`GL_INT_SAMPLER_2D_MULTISAMPLE` | `isampler2DMS`
`GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY` | `isampler2DMSArray`
`GL_INT_SAMPLER_BUFFER` | `isamplerBuffer`
`GL_INT_SAMPLER_2D_RECT` | `isampler2DRect`
`GL_UNSIGNED_INT_SAMPLER_1D` | `usampler1D`
`GL_UNSIGNED_INT_SAMPLER_2D` | `usampler2D`
`GL_UNSIGNED_INT_SAMPLER_3D` | `usampler3D`
`GL_UNSIGNED_INT_SAMPLER_CUBE` | `usamplerCube`
`GL_UNSIGNED_INT_SAMPLER_1D_ARRAY` | `usampler2DArray`
`GL_UNSIGNED_INT_SAMPLER_2D_ARRAY` | `usampler2DArray`
`GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE` | `usampler2DMS`
`GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY` | `usampler2DMSArray`
`GL_UNSIGNED_INT_SAMPLER_BUFFER` | `usamplerBuffer`
`GL_UNSIGNED_INT_SAMPLER_2D_RECT` | `usampler2DRect`

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 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 Name | 2.0 | 2.1 | 3.0 | 3.1 | 3.2 | 3.3 | 4.0 | 4.1 | 4.2 | 4.3 | 4.4 | 4.5
`glGetActiveUniformsiv` | - | - | - | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔

## 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/.