GLPROGRAMUNIFORM(3G)
πΈ NAME πΈ
okay bestie, gather round β this is the page for GLPROGRAMUNIFORM, and it lives in the [FIXME: manual] manual (yes, that's literally the manual name, don't @ me, it's a placeholder π).
So what is this whole family of functions for? One job, and it's giving main character energy:
glProgramUniform1f,glProgramUniform2f,glProgramUniform3f,glProgramUniform4fglProgramUniform1i,glProgramUniform2i,glProgramUniform3i,glProgramUniform4iglProgramUniform1ui,glProgramUniform2ui,glProgramUniform3ui,glProgramUniform4uiglProgramUniform1fv,glProgramUniform2fv,glProgramUniform3fv,glProgramUniform4fvglProgramUniform1iv,glProgramUniform2iv,glProgramUniform3iv,glProgramUniform4ivglProgramUniform1uiv,glProgramUniform2uiv,glProgramUniform3uiv,glProgramUniform4uivglProgramUniformMatrix2fv,glProgramUniformMatrix3fv,glProgramUniformMatrix4fvglProgramUniformMatrix2x3fv,glProgramUniformMatrix3x2fvglProgramUniformMatrix2x4fv,glProgramUniformMatrix4x2fvglProgramUniformMatrix3x4fv,glProgramUniformMatrix4x3fv
β¦and they all do exactly this: Specify the value of a uniform variable for a specified program object. That's the whole vibe. β¨
π C SPECIFICATION π
Copy-paste these bad boys exactly, no cap β I'm not fixing your typos for you π
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, GLint v0,
GLuint v1);
void glProgramUniform3ui(GLuint program, GLint location, GLint v0,
GLint v1, GLuint v2);
void glProgramUniform4ui(GLuint program, GLint location, GLint v0,
GLint v1, GLint v2, GLuint v3);
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);
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);
see how the Matrix ones all got that extra transpose bestie? yeah. we'll get to her. π¦
π PARAMETERS π
the lore. the cast of characters. let's meet them π«Ά
programβ the handle of the program that's holding the uniform variable you wanna mess with. Like, which program are we talking to? This one. πlocationβ the location of the uniform variable you're modifying. That's your address for the thing. πcountβ okay this one's got β¨two moodsβ¨ depending on which squad you roll with:- for the vector commands (
glProgramUniform*v): how many elements are gonna get modified. Should be1if the targeted uniform variable isn't an array, and1or more if it is an array. simple as. - for the matrix commands (
glProgramUniformMatrix*): how many matrices are gonna get modified. Should be1if the targeted uniform variable isn't an array of matrices, and1or more if it is an array of matrices. same energy, matrix edition π
- for the vector commands (
transposeβ matrix commands only, bestie. Tells you whether to transpose the matrix as the values get loaded into the uniform variable. flip it, don't flip it, your call π¦v0,v1,v2,v3β the scalar commands use these! They're the new values that go into the specified uniform variable. the actual goods πvalueβ vector and matrix commands only. It's a pointer to an array ofcountvalues that'll be used to update the specified uniform variable. pointers, my beloved π
and that's where part one leaves us, bestie β the plot thickens in the next bit πβ¨
β¨ DESCRIPTION β¨
Okay bestie, so glProgramUniform is the glow-up function that modifies the value of a uniform variable or a uniform variable array. The location of the uniform variable you're changing is specified by location, which should be a value returned by glGetUniformLocation(). And glProgramUniform operates on the program object specified by program. Slay.
The commands glProgramUniform{1|2|3|4}{f|i|ui} are the ones that change the value of the uniform variable specified by location using the values passed as arguments. The number in the command name should match the number of components in the data type of the specified uniform variable β like 1 for float, int, unsigned int, bool; 2 for vec2, ivec2, uvec2, bvec2, etc. The suffix f indicates floating-point values are being passed; the suffix i indicates integer values are being passed; the suffix ui indicates 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 should be used for uniform variables defined as unsigned int, uvec2, uvec3, uvec4, or arrays of these. The f variants should be used 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. Periodt.
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 β like 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 β for example, 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 π§
glProgramUniform1iandglProgramUniform1ivare literally 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 aGL_INVALID_OPERATIONerror. No cap.- If
countis greater than1and the indicated uniform variable is not an array, aGL_INVALID_OPERATIONerror 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_OPERATIONerror will be generated and the specified uniform variable will remain unchanged. - If
locationis a value other than-1and it does not represent a valid uniform variable location in withinprogram, an error will be generated, and no changes will be made to the uniform variable storage ofprogram. - If
locationis equal to-1, the data passed in will be silently ignored and the specified uniform variable will not be changed. Sneaky little no-op vibe, iykyk.
π ERRORS π
GL_INVALID_OPERATIONis generated ifprogramdoes not refer to a program object owned by the GL.GL_INVALID_OPERATIONis generated if the size of the uniform variable declared in the shader does not match the size indicated by theglProgramUniformcommand.GL_INVALID_OPERATIONis generated if one of the signed or unsigned integer variants of this function is used to load a uniform variable of typefloat,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 typeint,ivec2,ivec3,ivec4,unsigned int,uvec2,uvec3,uvec4, or an array of these.GL_INVALID_OPERATIONis generated if one of the signed integer variants of this function is used to load a uniform variable of typeunsigned int,uvec2,uvec3,uvec4, or an array of these.GL_INVALID_OPERATIONis generated if one of the unsigned integer variants of this function is used to load a uniform variable of typeint,ivec2,ivec3,ivec4, or an array of these.GL_INVALID_OPERATIONis generated iflocationis an invalid uniform location forprogramandlocationis not equal to-1.GL_INVALID_VALUEis generated ifcountis less than0.GL_INVALID_OPERATIONis generated ifcountis greater than1and the indicated uniform variable is not an array variable.GL_INVALID_OPERATIONis generated if a sampler is loaded using a command other thanglProgramUniform1iandglProgramUniform1iv.
π ASSOCIATED GETS π
glGetActiveUniform()with the handle of a program object and the index of an active uniform variableglGetUniform()with the handle of a program object and the location of a uniform variableglGetUniformLocation()with the handle of a program object and the name of a uniform variable
π«Ά Go off, bestie β your uniforms are gonna look iconic.
π VERSION SUPPORT π
okay bestie, before you panic at the wall of checkmarks and dashes: every single function down there has the exact same support story. Not even joking. So here's the vibe check in one line β β¨ nothing in OpenGL 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, or 4.0 β¨, and then from 4.1 onward it's all slay, all the way to 4.5. Periodt.
The table has two column groups: the Function / Feature Name on the left, and the OpenGL Version columns across the top, going 2.0 β 4.5. A - means nope, a β means yes queen.
So when you see literally any row below, read it as: - in 2.0, - in 2.1, - in 3.0, - in 3.1, - in 3.2, - in 3.3, - in 4.0, β in 4.1, β in 4.2, β in 4.3, β in 4.4, β in 4.5. π
πΈ the function rollout πΈ
glProgramUniform1fβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform1fvβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform1iβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform1ivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform1uiβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform1uivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform2fβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform2fvβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform2iβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform2ivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform2uiβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform2uivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform3fβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform3fvβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform3iβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform3ivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform3uiβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform3uivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform4fβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform4fvβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform4iβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5glProgramUniform4ivβ-2.0 Β·-2.1 Β·-3.0 Β·-3.1 Β·-3.2 Β·-3.3 Β·-4.0 Β·β4.1 Β·β4.2 Β·β4.3 Β·β4.4 Β·β4.5
and the table just keeps on going from there, so hold that thought bestie, the ui/uiv and vector friends are still queued up π
β¨
π quick legend before we keep going, bestie: these columns read left β right as2.0,2.1,3.0,3.1,3.2,3.3,4.0,4.1,4.2,4.3,4.4,4.5. A-means "nope, not here yet", a β means "yes queen, she's available." β¨
glProgramUniform4uiβ-------β β β β βglProgramUniform4uivβ-------β β β β βglProgramUniformMatrix2fvβ-------β β β β βglProgramUniformMatrix2x3fvβ-------β β β β βglProgramUniformMatrix2x4fvβ-------β β β β βglProgramUniformMatrix3fvβ-------β β β β βglProgramUniformMatrix3x2fvβ-------β β β β βglProgramUniformMatrix3x4fvβ-------β β β β βglProgramUniformMatrix4fvβ-------β β β β βglProgramUniformMatrix4x2fvβ-------β β β β βglProgramUniformMatrix4x3fvβ-------β β β β β
likeβ¦ every single one of them shows up starting at 4.1 and stays iconic through 4.5. no cap, consistent queen behaviour across the whole squad π
π¦ SEE ALSO
Go peep these when you're done here, they're the rest of the lore:
glLinkProgram()glUseProgram()
π COPYRIGHT
Copyright Β© 2003-2005 3Dlabs Inc. Ltd. Copyright Β© 2010-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 (yes bestie, it's listed twice, and we are NOT skipping one β every detail stays)
Copyright Β© 2003-2005 3Dlabs Inc. Ltd.
Copyright Β© 2010-2014 Khronos Group
and that's a wrap on GLPROGRAMUNIFORM(3G), bestie!! π«Άπ the page footer's giving [FIXME: source] for the source and version, dated 08/09/2021, filed under GLPROGRAMUNIFORM(3G) β stan a slightly unfinished footer, honestly. now go forth and glUseProgram() responsibly ππ
π¦ 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