glUniform4fv
时间: 2023-09-15 12:22:43 浏览: 50
glUniform4fv is a function in OpenGL that sets the value of a 4-component float vector uniform variable for the currently active shader program. This function is used to pass values to a uniform variable in the shader program.
The function signature of glUniform4fv is as follows:
```c
void glUniform4fv(GLint location, GLsizei count, const GLfloat* value);
```
- `location` refers to the location of the uniform variable in the shader program.
- `count` specifies the number of 4-component float vectors to be passed.
- `value` is a pointer to an array that contains the values to be passed to the uniform variable.
For example, if you have a uniform variable declared in your shader program as follows:
```glsl
uniform vec4 myUniform;
```
You can set its value using glUniform4fv as follows:
```c
GLfloat values[] = {1.0f, 2.0f, 3.0f, 4.0f};
glUniform4fv(location, 1, values);
```
This will set the value of the `myUniform` variable to (1.0, 2.0, 3.0, 4.0) in the currently active shader program.