片元着色器:
#version 330 core
out vec4 color;
//全局
uniform vec4 vertexColor;
void main()
{
color=vertexColor;
}
*.cpp:
//使用着色器程序
glUseProgram(shaderProgram);
//获取程序运行的时间
GLfloat timeValue = glfwGetTime();
//防止变负数
GLfloat greenValue = (sin(timeValue)/2)+0.5;
GLint vertexColorLocation = glGetUniformLocation(shaderProgram, "vertexColor");
glUniform4f(vertexColorLocation, 0.0f, greenValue, 0.0f, 1.0f);