Strange problem using #define vs passing uniform

Hi all,
I have come across a strange problem. If I define a constant as follows,

#define FUNC_X TILE_X/2.0
#define FUNC_Y TILE_Y/2.0

The code works fine. If I convert the variables to uniform and then pass the uniform from code like this,

//in glsl shader
uniform float FUNC_X;
uniform float FUNC_Y;

//in client code
glUniform1f(glGetUniformLocation(progID, "FUNC_X"), (tileX/2.0f));
glUniform1f(glGetUniformLocation(progID, "FUNC_Y"), (tileY/2.0f));

it does not give the correct output. I even tried changing the #define in the glsl code to this

float FUNC_X=TILE_X/2.0;
float FUNC_Y=TILE_Y/2.0;

and it also gives me the wrong result.
Why do i get this behaviour

Wild guess - is your program active when you set the uniforms?
Also, you may want to log with intercept with uniform logging on render call enabled.

Yes the program is active and the locations of the variables are also fine.

I will check this but it really beats me doing the same thing with uniforms or global variable it does not work, however with #define it works fine. I have the latest drivers installed. Any other thing that might be causing this behaviour.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.