GLAPI/glProgramUniform: Difference between revisions
4.0 API. |
m Changed glProgramUniformui variables to GLuint from GLint |
||
(7 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{infobox feature | {{infobox feature | ||
| name = glProgramUniform | | name = glProgramUniform, glProgramUniformMatrix | ||
| core = 4.1 | | core = 4.1 | ||
| core_extension = [http://www.opengl.org/registry/specs/ARB/separate_shader_objects.txt ARB_separate_shader_objects] | | core_extension = [http://www.opengl.org/registry/specs/ARB/separate_shader_objects.txt ARB_separate_shader_objects] | ||
Line 9: | Line 9: | ||
== Function Definition == | == Function Definition == | ||
void '''glProgramUniform1f'''(GLuint | void '''glProgramUniform1f'''(GLuint {{param|program}}, GLint {{param|location}}, GLfloat {{param|v0}}); | ||
void '''glProgramUniform2f'''(GLuint | void '''glProgramUniform2f'''(GLuint {{param|program}}, GLint {{param|location}}, GLfloat {{param|v0}}, GLfloat {{param|v1}}); | ||
void '''glProgramUniform3f'''(GLuint | void '''glProgramUniform3f'''(GLuint {{param|program}}, GLint {{param|location}}, GLfloat {{param|v0}}, GLfloat {{param|v1}}, GLfloat {{param|v2}}); | ||
void '''glProgramUniform4f'''(GLuint | void '''glProgramUniform4f'''(GLuint {{param|program}}, GLint {{param|location}}, GLfloat {{param|v0}}, GLfloat {{param|v1}}, GLfloat {{param|v2}}, GLfloat {{param|v3}}); | ||
void '''glProgramUniform1i'''(GLuint | void '''glProgramUniform1i'''(GLuint {{param|program}}, GLint {{param|location}}, GLint {{param|v0}}); | ||
void '''glProgramUniform2i'''(GLuint | void '''glProgramUniform2i'''(GLuint {{param|program}}, GLint {{param|location}}, GLint {{param|v0}}, GLint {{param|v1}}); | ||
void '''glProgramUniform3i'''(GLuint | void '''glProgramUniform3i'''(GLuint {{param|program}}, GLint {{param|location}}, GLint {{param|v0}}, GLint {{param|v1}}, GLint {{param|v2}}); | ||
void '''glProgramUniform4i'''(GLuint | void '''glProgramUniform4i'''(GLuint {{param|program}}, GLint {{param|location}}, GLint {{param|v0}}, GLint {{param|v1}}, GLint {{param|v2}}, GLint {{param|v3}}); | ||
void '''glProgramUniform1ui'''(GLuint | void '''glProgramUniform1ui'''(GLuint {{param|program}}, GLint {{param|location}}, GLuint {{param|v0}}); | ||
void '''glProgramUniform2ui'''(GLuint | void '''glProgramUniform2ui'''(GLuint {{param|program}}, GLint {{param|location}}, GLuint {{param|v0}}, GLuint {{param|v1}}); | ||
void '''glProgramUniform3ui'''(GLuint | void '''glProgramUniform3ui'''(GLuint {{param|program}}, GLint {{param|location}}, GLuint {{param|v0}}, GLuint {{param|v1}}, GLuint {{param|v2}}); | ||
void '''glProgramUniform4ui'''(GLuint | void '''glProgramUniform4ui'''(GLuint {{param|program}}, GLint {{param|location}}, GLuint {{param|v0}}, GLuint {{param|v1}}, GLuint {{param|v2}}, GLuint {{param|v3}}); | ||
; program | ; program | ||
Line 31: | Line 31: | ||
== Function Definition == | == Function Definition == | ||
void '''glProgramUniform1fv'''(GLuint | void '''glProgramUniform1fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniform2fv'''(GLuint | void '''glProgramUniform2fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniform3fv'''(GLuint | void '''glProgramUniform3fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniform4fv'''(GLuint | void '''glProgramUniform4fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniform1iv'''(GLuint | void '''glProgramUniform1iv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLint *{{param|value}}); | ||
void '''glProgramUniform2iv'''(GLuint | void '''glProgramUniform2iv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLint *{{param|value}}); | ||
void '''glProgramUniform3iv'''(GLuint | void '''glProgramUniform3iv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLint *{{param|value}}); | ||
void '''glProgramUniform4iv'''(GLuint | void '''glProgramUniform4iv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLint *{{param|value}}); | ||
void '''glProgramUniform1uiv'''(GLuint | void '''glProgramUniform1uiv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLuint *{{param|value}}); | ||
void '''glProgramUniform2uiv'''(GLuint | void '''glProgramUniform2uiv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLuint *{{param|value}}); | ||
void '''glProgramUniform3uiv'''(GLuint | void '''glProgramUniform3uiv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLuint *{{param|value}}); | ||
void '''glProgramUniform4uiv'''(GLuint | void '''glProgramUniform4uiv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, const GLuint *{{param|value}}); | ||
; program | ; program | ||
Line 51: | Line 51: | ||
: Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. | : Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. | ||
; value | ; value | ||
: Specifies a pointer to an array of | : Specifies a pointer to an array of {{param|count}} values that will be used to update the specified uniform variable. | ||
== Function Definition == | == Function Definition == | ||
void '''glProgramUniformMatrix2fv'''(GLuint | void '''glProgramUniformMatrix2fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix3fv'''(GLuint | void '''glProgramUniformMatrix3fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix4fv'''(GLuint | void '''glProgramUniformMatrix4fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix2x3fv'''(GLuint | void '''glProgramUniformMatrix2x3fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix3x2fv'''(GLuint | void '''glProgramUniformMatrix3x2fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix2x4fv'''(GLuint | void '''glProgramUniformMatrix2x4fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix4x2fv'''(GLuint | void '''glProgramUniformMatrix4x2fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix3x4fv'''(GLuint | void '''glProgramUniformMatrix3x4fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
void '''glProgramUniformMatrix4x3fv'''(GLuint | void '''glProgramUniformMatrix4x3fv'''(GLuint {{param|program}}, GLint {{param|location}}, GLsizei {{param|count}}, GLboolean {{param|transpose}}, const GLfloat *{{param|value}}); | ||
; program | ; program | ||
Line 74: | Line 74: | ||
: Specifies whether to transpose the matrix as the values are loaded into the uniform variable. | : Specifies whether to transpose the matrix as the values are loaded into the uniform variable. | ||
; value | ; value | ||
: Specifies a pointer to an array of | : Specifies a pointer to an array of {{param|count}} values that will be used to update the specified uniform variable. | ||
== Description == | == Description == | ||
'''glProgramUniform''' modifies the value of a uniform variable or a uniform variable array. The location of the uniform variable to be modified is specified by | '''glProgramUniform''' modifies the value of a uniform variable or a uniform variable array. The location of the uniform variable to be modified is specified by {{param|location}}, which should be a value returned by {{apifunc|glGetUniformLocation}}. '''glProgramUniform''' operates on the program object specified by {{param|program}}. | ||
The commands '''glProgramUniform{1|2|3|4}{f|i|ui}''' are used to change the value of the uniform variable specified by | The commands '''glProgramUniform{1|2|3|4}{f|i|ui}''' are used to change the value of the uniform variable specified by {{param|location}} using the values passed as arguments. The number specified in the command should match the number of components in the data type of the specified uniform variable (e.g., '''1''' for {{code|float}}, {{code|int}}, {{code|unsigned int}}, {{code|bool}}; '''2''' for {{code|vec2}}, {{code|ivec2}}, {{code|uvec2}}, {{code|bvec2}}, etc.). The suffix '''f''' indicates that floating-point values are being passed; the suffix '''i''' indicates that integer values are being passed; the suffix '''ui''' indicates that unsigned integer values are being passed, and this type should also match the data type of the specified uniform variable. The '''i''' variants of this function should be used to provide values for uniform variables defined as {{code|int}}, {{code|ivec2}}, {{code|ivec3}}, {{code|ivec4}}, or arrays of these. The '''ui''' variants of this function should be used to provide values for uniform variables defined as {{code|unsigned int}}, {{code|uvec2}}, {{code|uvec3}}, {{code|uvec4}}, or arrays of these. The '''f''' variants should be used to provide values for uniform variables of type {{code|float}}, {{code|vec2}}, {{code|vec3}}, {{code|vec4}}, or arrays of these. Either the '''i''', '''ui''' or '''f''' variants may be used to provide values for uniform variables of type {{code|bool}}, {{code|bvec2}}, {{code|bvec3}}, {{code|bvec4}}, or arrays of these. The uniform variable will be set to {{code|false}} if the input value is 0 or 0.0f, and it will be set to {{code|true}} otherwise. | ||
All active uniform variables defined in a program object are initialized to 0 when the program object is linked successfully. They retain the values assigned to them by a call to '''glProgramUniform''' until the next successful link operation occurs on the program object, when they are once again initialized to 0. | All active uniform variables defined in a program object are initialized to 0 when the program object is linked successfully. They retain the values assigned to them by a call to '''glProgramUniform''' until the next successful link operation occurs on the program object, when they are once again initialized to 0. | ||
The commands '''glProgramUniform{1|2|3|4}{f|i|ui}v''' can be used to modify a single uniform variable or a uniform variable array. These commands pass a count and a pointer to the values to be loaded into a uniform variable or a uniform variable array. A count of 1 should be used if modifying the value of a single uniform variable, and a count of 1 or greater can be used to modify an entire array or part of an array. When loading ''n'' elements starting at an arbitrary position ''m'' in a uniform variable array, elements ''m'' + ''n'' - 1 in the array will be replaced with the new values. If | The commands '''glProgramUniform{1|2|3|4}{f|i|ui}v''' can be used to modify a single uniform variable or a uniform variable array. These commands pass a count and a pointer to the values to be loaded into a uniform variable or a uniform variable array. A count of 1 should be used if modifying the value of a single uniform variable, and a count of 1 or greater can be used to modify an entire array or part of an array. When loading ''n'' elements starting at an arbitrary position ''m'' in a uniform variable array, elements ''m'' + ''n'' - 1 in the array will be replaced with the new values. If {{param|m}} + {{param|n}} - 1 is larger than the size of the uniform variable array, values for all array elements beyond the end of the array will be ignored. The number specified in the name of the command indicates the number of components for each element in {{param|value}}, and it should match the number of components in the data type of the specified uniform variable (e.g., '''1''' for {{code|float}}, {{code|int}}, {{code|bool}}; '''2''' for {{code|vec2}}, {{code|ivec2}}, {{code|bvec2}}, etc.). The data type specified in the name of the command must match the data type for the specified uniform variable as described previously for '''glProgramUniform{1|2|3|4}{f|i|ui}'''. | ||
For uniform variable arrays, each element of the array is considered to be of the type indicated in the name of the command (e.g., '''glProgramUniform3f''' or '''glProgramUniform3fv''' can be used to load a uniform variable array of type vec3). The number of elements of the uniform variable array to be modified is specified by | For uniform variable arrays, each element of the array is considered to be of the type indicated in the name of the command (e.g., '''glProgramUniform3f''' or '''glProgramUniform3fv''' can be used to load a uniform variable array of type vec3). The number of elements of the uniform variable array to be modified is specified by {{param|count}} | ||
The commands '''glProgramUniformMatrix{2|3|4|2x3|3x2|2x4|4x2|3x4|4x3}fv''' are used to modify a matrix or an array of matrices. The numbers in the command name are interpreted as the dimensionality of the matrix. The number '''2''' indicates a 2 × 2 matrix (i.e., 4 values), the number '''3''' indicates a 3 × 3 matrix (i.e., 9 values), and the number '''4''' indicates a 4 × 4 matrix (i.e., 16 values). Non-square matrix dimensionality is explicit, with the first number representing the number of columns and the second number representing the number of rows. For example, '''2x4''' indicates a 2 × 4 matrix with 2 columns and 4 rows (i.e., 8 values). If | The commands '''glProgramUniformMatrix{2|3|4|2x3|3x2|2x4|4x2|3x4|4x3}fv''' are used to modify a matrix or an array of matrices. The numbers in the command name are interpreted as the dimensionality of the matrix. The number '''2''' indicates a 2 × 2 matrix (i.e., 4 values), the number '''3''' indicates a 3 × 3 matrix (i.e., 9 values), and the number '''4''' indicates a 4 × 4 matrix (i.e., 16 values). Non-square matrix dimensionality is explicit, with the first number representing the number of columns and the second number representing the number of rows. For example, '''2x4''' indicates a 2 × 4 matrix with 2 columns and 4 rows (i.e., 8 values). If {{param|transpose}} is {{enum|GL_FALSE}}, each matrix is assumed to be supplied in column major order. If {{param|transpose}} is {{enum|GL_TRUE}}, each matrix is assumed to be supplied in row major order. The {{param|count}} argument indicates the number of matrices to be passed. A count of 1 should be used if modifying the value of a single matrix, and a count greater than 1 can be used to modify an array of matrices. | ||
== Notes == | == Notes == | ||
'''glProgramUniform1i''' and '''glProgramUniform1iv''' are the only two functions that may be used to load uniform variables defined as sampler types. Loading samplers with any other function will result in a {{ | '''glProgramUniform1i''' and '''glProgramUniform1iv''' are the only two functions that may be used to load uniform variables defined as sampler types. Loading samplers with any other function will result in a {{enum|GL_INVALID_OPERATION}} error. | ||
If | If {{param|count}} is greater than 1 and the indicated uniform variable is not an array, a {{enum|GL_INVALID_OPERATION}} error is generated and the specified uniform variable will remain unchanged. | ||
Other than the preceding exceptions, if the type and size of the uniform variable as defined in the shader do not match the type and size specified in the name of the command used to load its value, a {{ | Other than the preceding exceptions, if the type and size of the uniform variable as defined in the shader do not match the type and size specified in the name of the command used to load its value, a {{enum|GL_INVALID_OPERATION}} error will be generated and the specified uniform variable will remain unchanged. | ||
If | If {{param|location}} is a value other than -1 and it does not represent a valid uniform variable location in within {{param|program}}, an error will be generated, and no changes will be made to the uniform variable storage of {{param|program}}. If {{param|location}} is equal to -1, the data passed in will be silently ignored and the specified uniform variable will not be changed. | ||
== Errors == | == Errors == | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if {{param|program}} does not refer to a program object owned by the GL. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if the size of the uniform variable declared in the shader does not match the size indicated by the '''glProgramUniform''' command. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if one of the signed or unsigned integer variants of this function is used to load a uniform variable of type {{code|float}}, {{code|vec2}}, {{code|vec3}}, {{code|vec4}}, or an array of these, or if one of the floating-point variants of this function is used to load a uniform variable of type {{code|int}}, {{code|ivec2}}, {{code|ivec3}}, {{code|ivec4}}, {{code|unsigned int}}, {{code|uvec2}}, {{code|uvec3}}, {{code|uvec4}}, or an array of these. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if one of the signed integer variants of this function is used to load a uniform variable of type {{code|unsigned int}}, {{code|uvec2}}, {{code|uvec3}}, {{code|uvec4}}, or an array of these. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if one of the unsigned integer variants of this function is used to load a uniform variable of type {{code|int}}, {{code|ivec2}}, {{code|ivec3}}, {{code|ivec4}}, or an array of these. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if {{param|location}} is an invalid uniform location for {{param|program}} and {{param|location}} is not equal to -1. | ||
{{ | {{enum|GL_INVALID_VALUE}} is generated if {{param|count}} is less than 0. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if {{param|count}} is greater than 1 and the indicated uniform variable is not an array variable. | ||
{{ | {{enum|GL_INVALID_OPERATION}} is generated if a sampler is loaded using a command other than '''glProgramUniform1i''' and '''glProgramUniform1iv'''. | ||
== Associated Gets == | == Associated Gets == | ||
{{apifunc|glGetActiveUniform}} with the handle of a program object and the index of an active uniform variable | |||
{{apifunc|glGetUniform}} with the handle of a program object and the location of a uniform variable | |||
{{apifunc|glGetUniformLocation}} with the handle of a program object and the name of a uniform variable | |||
== See Also == | == See Also == | ||
{{apifunc|glCreateProgram}}, {{apifunc|glLinkProgram}} | |||
== Copyright == | == Copyright == | ||
Line 136: | Line 136: | ||
Copyright © 2003-2005 3Dlabs Inc. Ltd. Copyright © 2010 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/ http://opencontent.org/openpub/]. | Copyright © 2003-2005 3Dlabs Inc. Ltd. Copyright © 2010 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/ http://opencontent.org/openpub/]. | ||
[[Category:API Reference | [[Category:Core API Ref Shader Program Usage and State|ProgramUniform]] | ||
[[Category:Core API Reference|ProgramUniform]] | |||
[[Category:Program Object API State Functions|ProgramUniform]] |
Latest revision as of 21:29, 4 November 2016
Core in version | 4.6 | |
---|---|---|
Core since version | 4.1 | |
Core ARB extension | ARB_separate_shader_objects |
glProgramUniform and glProgramUniformMatrix: Specify the value of a uniform variable for a specified program object
Function Definition
void glProgramUniform1f(GLuint program, GLint location, GLfloat v0); void glProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1); void glProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); void glProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); void glProgramUniform1i(GLuint program, GLint location, GLint v0); void glProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1); void glProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2); void glProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); void glProgramUniform1ui(GLuint program, GLint location, GLuint v0); void glProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1); void glProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); void glProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
- program
- Specifies the handle of the program containing the uniform variable to be modified.
- location
- Specifies the location of the uniform variable to be modified.
- v0, v1, v2, v3
- Specifies the new values to be used for the specified uniform variable.
Function Definition
void glProgramUniform1fv(GLuint program, GLint location, GLsizei count, const GLfloat *value); void glProgramUniform2fv(GLuint program, GLint location, GLsizei count, const GLfloat *value); void glProgramUniform3fv(GLuint program, GLint location, GLsizei count, const GLfloat *value); void glProgramUniform4fv(GLuint program, GLint location, GLsizei count, const GLfloat *value); void glProgramUniform1iv(GLuint program, GLint location, GLsizei count, const GLint *value); void glProgramUniform2iv(GLuint program, GLint location, GLsizei count, const GLint *value); void glProgramUniform3iv(GLuint program, GLint location, GLsizei count, const GLint *value); void glProgramUniform4iv(GLuint program, GLint location, GLsizei count, const GLint *value); void glProgramUniform1uiv(GLuint program, GLint location, GLsizei count, const GLuint *value); void glProgramUniform2uiv(GLuint program, GLint location, GLsizei count, const GLuint *value); void glProgramUniform3uiv(GLuint program, GLint location, GLsizei count, const GLuint *value); void glProgramUniform4uiv(GLuint program, GLint location, GLsizei count, const GLuint *value);
- program
- Specifies the handle of the program containing the uniform variable to be modified.
- location
- Specifies the location of the uniform value to be modified.
- count
- Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array.
- value
- Specifies a pointer to an array of count values that will be used to update the specified uniform variable.
Function Definition
void glProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void glProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
- program
- Specifies the handle of the program containing the uniform variable to be modified.
- location
- Specifies the location of the uniform value to be modified.
- count
- Specifies the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices.
- transpose
- Specifies whether to transpose the matrix as the values are loaded into the uniform variable.
- value
- Specifies a pointer to an array of count values that will be used to update the specified uniform variable.
Description
glProgramUniform modifies the value of a uniform variable or a uniform variable array. The location of the uniform variable to be modified is specified by location, which should be a value returned by glGetUniformLocation. glProgramUniform operates on the program object specified by program.
The commands glProgramUniform{1|2|3|4}{f|i|ui} are used to change the value of the uniform variable specified by location using the values passed as arguments. The number specified in the command should match the number of components in the data type of the specified uniform variable (e.g., 1 for float, int, unsigned int, bool; 2 for vec2, ivec2, uvec2, bvec2, etc.). The suffix f indicates that floating-point values are being passed; the suffix i indicates that integer values are being passed; the suffix ui indicates that unsigned integer values are being passed, and this type should also match the data type of the specified uniform variable. The i variants of this function should be used to provide values for uniform variables defined as int, ivec2, ivec3, ivec4, or arrays of these. The ui variants of this function should be used to provide values for uniform variables defined as unsigned int, uvec2, uvec3, uvec4, or arrays of these. The f variants should be used to provide values for uniform variables of type float, vec2, vec3, vec4, or arrays of these. Either the i, ui or f variants may be used to provide values for uniform variables of type bool, bvec2, bvec3, bvec4, or arrays of these. The uniform variable will be set to false if the input value is 0 or 0.0f, and it will be set to true otherwise.
All active uniform variables defined in a program object are initialized to 0 when the program object is linked successfully. They retain the values assigned to them by a call to glProgramUniform until the next successful link operation occurs on the program object, when they are once again initialized to 0.
The commands glProgramUniform{1|2|3|4}{f|i|ui}v can be used to modify a single uniform variable or a uniform variable array. These commands pass a count and a pointer to the values to be loaded into a uniform variable or a uniform variable array. A count of 1 should be used if modifying the value of a single uniform variable, and a count of 1 or greater can be used to modify an entire array or part of an array. When loading n elements starting at an arbitrary position m in a uniform variable array, elements m + n - 1 in the array will be replaced with the new values. If m + n - 1 is larger than the size of the uniform variable array, values for all array elements beyond the end of the array will be ignored. The number specified in the name of the command indicates the number of components for each element in value, and it should match the number of components in the data type of the specified uniform variable (e.g., 1 for float, int, bool; 2 for vec2, ivec2, bvec2, etc.). The data type specified in the name of the command must match the data type for the specified uniform variable as described previously for glProgramUniform{1|2|3|4}{f|i|ui}.
For uniform variable arrays, each element of the array is considered to be of the type indicated in the name of the command (e.g., glProgramUniform3f or glProgramUniform3fv can be used to load a uniform variable array of type vec3). The number of elements of the uniform variable array to be modified is specified by count
The commands glProgramUniformMatrix{2|3|4|2x3|3x2|2x4|4x2|3x4|4x3}fv are used to modify a matrix or an array of matrices. The numbers in the command name are interpreted as the dimensionality of the matrix. The number 2 indicates a 2 × 2 matrix (i.e., 4 values), the number 3 indicates a 3 × 3 matrix (i.e., 9 values), and the number 4 indicates a 4 × 4 matrix (i.e., 16 values). Non-square matrix dimensionality is explicit, with the first number representing the number of columns and the second number representing the number of rows. For example, 2x4 indicates a 2 × 4 matrix with 2 columns and 4 rows (i.e., 8 values). If transpose is GL_FALSE, each matrix is assumed to be supplied in column major order. If transpose is GL_TRUE, each matrix is assumed to be supplied in row major order. The count argument indicates the number of matrices to be passed. A count of 1 should be used if modifying the value of a single matrix, and a count greater than 1 can be used to modify an array of matrices.
Notes
glProgramUniform1i and glProgramUniform1iv are the only two functions that may be used to load uniform variables defined as sampler types. Loading samplers with any other function will result in a GL_INVALID_OPERATION error.
If count is greater than 1 and the indicated uniform variable is not an array, a GL_INVALID_OPERATION error is generated and the specified uniform variable will remain unchanged.
Other than the preceding exceptions, if the type and size of the uniform variable as defined in the shader do not match the type and size specified in the name of the command used to load its value, a GL_INVALID_OPERATION error will be generated and the specified uniform variable will remain unchanged.
If location is a value other than -1 and it does not represent a valid uniform variable location in within program, an error will be generated, and no changes will be made to the uniform variable storage of program. If location is equal to -1, the data passed in will be silently ignored and the specified uniform variable will not be changed.
Errors
GL_INVALID_OPERATION is generated if program does not refer to a program object owned by the GL.
GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glProgramUniform command.
GL_INVALID_OPERATION is generated if one of the signed or unsigned integer variants of this function is used to load a uniform variable of type float, vec2, vec3, vec4, or an array of these, or if one of the floating-point variants of this function is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4, or an array of these.
GL_INVALID_OPERATION is generated if one of the signed integer variants of this function is used to load a uniform variable of type unsigned int, uvec2, uvec3, uvec4, or an array of these.
GL_INVALID_OPERATION is generated if one of the unsigned integer variants of this function is used to load a uniform variable of type int, ivec2, ivec3, ivec4, or an array of these.
GL_INVALID_OPERATION is generated if location is an invalid uniform location for program and location is not equal to -1.
GL_INVALID_VALUE is generated if count is less than 0.
GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.
GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glProgramUniform1i and glProgramUniform1iv.
Associated Gets
glGetActiveUniform with the handle of a program object and the index of an active uniform variable
glGetUniform with the handle of a program object and the location of a uniform variable
glGetUniformLocation with the handle of a program object and the name of a uniform variable
See Also
glCreateProgram, glLinkProgram
Copyright
Copyright © 2003-2005 3Dlabs Inc. Ltd. Copyright © 2010 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/.