glGetUniformfv, glGetUniformiv - Returns the value of a uniform variable
Contents
Associated Gets
glGetActiveUniform() with arguments program and the index of an active uniform variable
glGetProgram() with arguments program and GL_ACTIVE_UNIFORMS or GL_ACTIVE_UNIFORM_MAX_LENGTHglGetUniformLocation() with arguments program and the name of a uniform variable
glIsProgram()
C Specification
voidglGetUniformfv(GLuintprogram,GLintlocation,GLfloat*params);voidglGetUniformiv(GLuintprogram,GLintlocation,GLint*params);voidglGetUniformuiv(GLuintprogram,GLintlocation,GLuint*params);voidglGetUniformdv(GLuintprogram,GLintlocation,GLdouble*params);voidglGetnUniformfv(GLuintprogram,GLintlocation,GLsizeibufSize,GLfloat*params);voidglGetnUniformiv(GLuintprogram,GLintlocation,GLsizeibufSize,GLint*params);voidglGetnUniformuiv(GLuintprogram,GLintlocation,GLsizeibufSize,GLuint*params);voidglGetnUniformdv(GLuintprogram,GLintlocation,GLsizeibufSize,GLdouble*params);
Copyright
Copyright © 2003-2005 3Dlabs Inc. Ltd.
Copyright © 2010-2014 Khronos Group
[FIXME: source] 11/18/2024 GLGETUNIFORM(3G)
Description
glGetUniform and glGetnUniform return in params the value(s) of the specified uniform variable. The type
of the uniform variable specified by location determines the number of values returned. If the uniform
variable is defined in the shader as a boolean, int, or float, a single value will be returned. If it is
defined as a vec2, ivec2, or bvec2, two values will be returned. If it is defined as a vec3, ivec3, or
bvec3, three values will be returned, and so on. To query values stored in uniform variables declared as
arrays, call glGetUniform for each element of the array. To query values stored in uniform variables
declared as structures, call glGetUniform for each field in the structure. The values for uniform
variables declared as a matrix will be returned in column major order.
The locations assigned to uniform variables are not known until the program object is linked. After
linking has occurred, the command glGetUniformLocation() can be used to obtain the location of a uniform
variable. This location value can then be passed to glGetUniform or glGetnUniform in order to query the
current value of the uniform variable. After a program object has been linked successfully, the index
values for uniform variables remain fixed until the next link command occurs. The uniform variable values
can only be queried after a link if the link was successful.
The only difference between glGetUniform and glGetnUniform is that glGetnUniform will generate an error
if size of the params buffer,as described by bufSize, is not large enough to hold the result data.
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_OPERATION is generated if program has not been successfully linked.
GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location
for the specified program object.
GL_INVALID_OPERATION is generated by glGetnUniform if the buffer size required to store the requested
data is greater than bufSize.
Name
glGetUniformfv, glGetUniformiv - Returns the value of a uniform variable
Notes
If an error is generated, no change is made to the contents of params.
Parameters
program
Specifies the program object to be queried.
location
Specifies the location of the uniform variable to be queried.
bufSize
Specifies the size of the buffer params.
params
Returns the value of the specified uniform variable.
See Also
glCreateProgram(), glLinkProgram(), glUniform()
Version Support
┌──────────────────┬───────────────────────────────────────────────────────────────────────┐
│ │ OpenGLVersion │
├──────────────────┼─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┤
│ Function │ 2.0 │ 2.1 │ 3.0 │ 3.1 │ 3.2 │ 3.3 │ 4.0 │ 4.1 │ 4.2 │ 4.3 │ 4.4 │ 4.5 │
│ / │ │ │ │ │ │ │ │ │ │ │ │ │
│ Feature │ │ │ │ │ │ │ │ │ │ │ │ │
│ Name │ │ │ │ │ │ │ │ │ │ │ │ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetUniformdv │ - │ - │ - │ - │ - │ - │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetUniformfv │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetUniformiv │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetUniformuiv │ - │ - │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetnUniformdv │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetnUniformfv │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetnUniformiv │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ ✔ │
├──────────────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ glGetnUniformuiv │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ - │ ✔ │
└──────────────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
