Jump to content
  • Advertisement
Sign in to follow this  
Asem

OpenGL glUniform problem

This topic is 3716 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'm using glGetUniformLocation but I can't for some reason get a valid location. My test shader looks like this:

//Fragment shader
uniform vec4 col;


void main()
{
	gl_FragColor = col * vec4(1.0, 1.0, 0.0, 1.0);
}



//Then (actual cpp file)

int loc = glGetUniformLocation(programObject, "col");

//loc returns -1 instead loc>=0

glUniform4f(loc, 0.5, 0.1, 0.6, 1.0);





This is just a basic shader to let me test if I can get the uniform variable. I tested to see if maybe I read the file wrong but that's not it. If I use col as a regular vec4 it works fine and in this case will return turn my object yellow. I've read and researched for hours and I can't see anything different other than maybe a driver issue or that to the glsl compile 'col' is an inactive variable which it looks like it to me, right? I did check to see if I'm returning a valid programObject and I am so I'm at a lost now. The shader basically stops to work when I try to use uniform. Is there a glEnable that tells opengl to use shaders or what? Please help and thanks for any answers you come up with. I have an ATI X1 and an nvidia 7800gs (I've tested on both but same thing)

Share this post


Link to post
Share on other sites
Advertisement
Funny thing just happened. After switching out my video card to the nvidia one it was able to find my uniform variable. I'm starting to think it's the ide(dev-c++ skiping or not doing something properly) or maybe the compiler(mingw but I would think this is unlikely).

This isn't the only funny thing I've ran into ( for some reason the if statement didn't seem to work right some days ago).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!