Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

OpenGL change float in vertex shader

This topic is 2822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

// 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..?

Share this post

Link to post
Share on other sites
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*().

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!