change float in vertex shader

Started by
0 comments, last by Aks9 12 years, 2 months ago
I can't figure out how to change a value in my vertex shader. What i do in opengl is the following:


//i bind my shader
shader.bind();

// Then trying to set the value in my vertex shader like so:
GLuint test = glGetUniformLocation(shader.id(), "Test");
glUniform1f(test, 6.0f);


This is the value i want to change in my vertex shader:

uniform float Test = 0.66; // Doesn't work
//const float Test = 0.66; // Works


But my shader doesn't work when i try that. If i comment the OpenGL part out and if use the float as a const instead of a uniform then my shader works fine. But i want to be able to change that value from my OpenGL game.

Can someone tell me what i'm doing wrong..?
Advertisement
Uniforms are constant per primitive. You cannot define or change their values from within the shader.
But you can change their values from your application using glUniform*().

This topic is closed to new replies.

Advertisement