Graphics Reference
In-Depth Information
are needed to figure out how to load it with data. Once we have the name
of the uniform, we can find its location using
glGetUniformLocation
. The
uniform location is an integer value used to identify the location of the
uniform in the program (note that uniforms in the named uniform blocks
are not assigned a location). That location value is used by subsequent calls
for loading uniforms with values (e.g.,
glUniformlf
).
GLint
glGetUniformLocation
(GLuint
program
,
const GLchar*
name
)
program
handle to the program object
name
the name of the uniform for which to get the location
This function will return the location of the uniform given by
name
.
If
the uniform is not an active uniform in the program, then the return
value will be -1. Once we have the uniform location along with its type
and array size, we can then load the uniform with values. A number of
different functions for loading uniforms are available, with different
functions for each uniform type.
void
glUniform1f
(GLint
location
, GLfloat
x
)
void
glUniform1fv
(GLint
location
, GLsizei
count
,
const GLfloat*
value
)
void
glUniform1i
(GLint
location
, GLint
x
)
void
glUniform1iv
(GLint
location
, GLsizei
count
,
const GLint*
value
)
void
glUniform1ui
(GLint
location
, GLuint
x
)
void
glUniform1uiv
(GLint
location
, GLsizei
count
,
const GLuint*
value
)
void
glUniform2f
(GLint
location
, GLfloat
x
, GLfloat
y
)
void
glUniform2fv
(GLint
location
, GLsizei
count
,
const GLfloat*
value
)
void
glUniform2i
(GLint
location
, GLint
x
, GLint
y
)
void
glUniform2iv
(GLint
location
, GLsizei
count
,
const GLint*
value
)
void
glUniform2ui
(GLint
location
, GLuint
x
, GLuint
y
)
void
glUniform2uiv
(GLint
location
, GLsizei
count
,
const GLuint*
value
)
(continues)