Not getting uniform from Shader fragment with glGetUniformLocation [on hold]











up vote
0
down vote

favorite












My fragment shader looks like this:



#version 450
out vec4 frag_colour;
uniform vec4 u_Color;
void main () {
frag_colour = u_Color;
}


colorGlobal is a float changing its value upon buttonclick, initialized to float 0.0. when I run this code:



int locationColour = glGetUniformLocation(shader_program, "u_Color");

glUniform4f(locationColour, 0.9f, 0.3f, colorGlobal, 1.0f);


in my while (!glfwWindowShouldClose (window))



im getting -1 printed out for the locationColour. What could I have missed here?



when hardcoding the fragment shader like this:



#version 450
out vec4 frag_colour;
void main () {
frag_colour = vec4 (0.3, 0.3, 0.5, 1.0);
}


Then im getting a purple triangle. Any suggestions on why the uniform is not working properly?










share|improve this question















put on hold as off-topic by Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya 23 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Did you glUseProgram before glUniform4f?
    – Rabbid76
    yesterday










  • Yeah, right before the while loop.
    – orgee
    yesterday










  • Are you also calling glUniform4f before the while loop? Note that the currently attached program must be shader_program for you to be able to set the uniform for it.
    – wdc
    yesterday








  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    yesterday










  • Thanks alot for your time guys. I did a horrible misstake, declared my shader_program as a global int and also a local int in the function where i link, attach the files. So I was using the global one which is only an int for the glGetUniformLocation.
    – orgee
    yesterday

















up vote
0
down vote

favorite












My fragment shader looks like this:



#version 450
out vec4 frag_colour;
uniform vec4 u_Color;
void main () {
frag_colour = u_Color;
}


colorGlobal is a float changing its value upon buttonclick, initialized to float 0.0. when I run this code:



int locationColour = glGetUniformLocation(shader_program, "u_Color");

glUniform4f(locationColour, 0.9f, 0.3f, colorGlobal, 1.0f);


in my while (!glfwWindowShouldClose (window))



im getting -1 printed out for the locationColour. What could I have missed here?



when hardcoding the fragment shader like this:



#version 450
out vec4 frag_colour;
void main () {
frag_colour = vec4 (0.3, 0.3, 0.5, 1.0);
}


Then im getting a purple triangle. Any suggestions on why the uniform is not working properly?










share|improve this question















put on hold as off-topic by Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya 23 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Did you glUseProgram before glUniform4f?
    – Rabbid76
    yesterday










  • Yeah, right before the while loop.
    – orgee
    yesterday










  • Are you also calling glUniform4f before the while loop? Note that the currently attached program must be shader_program for you to be able to set the uniform for it.
    – wdc
    yesterday








  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    yesterday










  • Thanks alot for your time guys. I did a horrible misstake, declared my shader_program as a global int and also a local int in the function where i link, attach the files. So I was using the global one which is only an int for the glGetUniformLocation.
    – orgee
    yesterday















up vote
0
down vote

favorite









up vote
0
down vote

favorite











My fragment shader looks like this:



#version 450
out vec4 frag_colour;
uniform vec4 u_Color;
void main () {
frag_colour = u_Color;
}


colorGlobal is a float changing its value upon buttonclick, initialized to float 0.0. when I run this code:



int locationColour = glGetUniformLocation(shader_program, "u_Color");

glUniform4f(locationColour, 0.9f, 0.3f, colorGlobal, 1.0f);


in my while (!glfwWindowShouldClose (window))



im getting -1 printed out for the locationColour. What could I have missed here?



when hardcoding the fragment shader like this:



#version 450
out vec4 frag_colour;
void main () {
frag_colour = vec4 (0.3, 0.3, 0.5, 1.0);
}


Then im getting a purple triangle. Any suggestions on why the uniform is not working properly?










share|improve this question















My fragment shader looks like this:



#version 450
out vec4 frag_colour;
uniform vec4 u_Color;
void main () {
frag_colour = u_Color;
}


colorGlobal is a float changing its value upon buttonclick, initialized to float 0.0. when I run this code:



int locationColour = glGetUniformLocation(shader_program, "u_Color");

glUniform4f(locationColour, 0.9f, 0.3f, colorGlobal, 1.0f);


in my while (!glfwWindowShouldClose (window))



im getting -1 printed out for the locationColour. What could I have missed here?



when hardcoding the fragment shader like this:



#version 450
out vec4 frag_colour;
void main () {
frag_colour = vec4 (0.3, 0.3, 0.5, 1.0);
}


Then im getting a purple triangle. Any suggestions on why the uniform is not working properly?







opengl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Rabbid76

29.3k112742




29.3k112742










asked yesterday









orgee

112




112




put on hold as off-topic by Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya 23 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya 23 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Did you glUseProgram before glUniform4f?
    – Rabbid76
    yesterday










  • Yeah, right before the while loop.
    – orgee
    yesterday










  • Are you also calling glUniform4f before the while loop? Note that the currently attached program must be shader_program for you to be able to set the uniform for it.
    – wdc
    yesterday








  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    yesterday










  • Thanks alot for your time guys. I did a horrible misstake, declared my shader_program as a global int and also a local int in the function where i link, attach the files. So I was using the global one which is only an int for the glGetUniformLocation.
    – orgee
    yesterday
















  • 1




    Did you glUseProgram before glUniform4f?
    – Rabbid76
    yesterday










  • Yeah, right before the while loop.
    – orgee
    yesterday










  • Are you also calling glUniform4f before the while loop? Note that the currently attached program must be shader_program for you to be able to set the uniform for it.
    – wdc
    yesterday








  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    yesterday










  • Thanks alot for your time guys. I did a horrible misstake, declared my shader_program as a global int and also a local int in the function where i link, attach the files. So I was using the global one which is only an int for the glGetUniformLocation.
    – orgee
    yesterday










1




1




Did you glUseProgram before glUniform4f?
– Rabbid76
yesterday




Did you glUseProgram before glUniform4f?
– Rabbid76
yesterday












Yeah, right before the while loop.
– orgee
yesterday




Yeah, right before the while loop.
– orgee
yesterday












Are you also calling glUniform4f before the while loop? Note that the currently attached program must be shader_program for you to be able to set the uniform for it.
– wdc
yesterday






Are you also calling glUniform4f before the while loop? Note that the currently attached program must be shader_program for you to be able to set the uniform for it.
– wdc
yesterday






1




1




Do you glLinkProgram before glGetUniformLocation?
– Rabbid76
yesterday




Do you glLinkProgram before glGetUniformLocation?
– Rabbid76
yesterday












Thanks alot for your time guys. I did a horrible misstake, declared my shader_program as a global int and also a local int in the function where i link, attach the files. So I was using the global one which is only an int for the glGetUniformLocation.
– orgee
yesterday






Thanks alot for your time guys. I did a horrible misstake, declared my shader_program as a global int and also a local int in the function where i link, attach the files. So I was using the global one which is only an int for the glGetUniformLocation.
– orgee
yesterday



















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ