I am trying to draw a triangle which changes color over time. My implementation is by using uniform variable.
my fragment shader-
#version 330 core
out vec4 FragColor;
uniform float var;
void main()
{
FragColor = vec4(var*0.2, var*0.333, var*0.7, 1.0f);
}
in render loop
while (!glfwWindowShouldClose(window))
{
time = 1.0f*fabs(sin(glfwGetTime()*3.1416f));
processInput(window);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
shader1.use();
shader1.setFloat("var", time);
glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, 0, 3);
glfwPollEvents();
glfwSwapBuffers(window);
}
But the triangle goes blue to dark. What is missing?