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 yesterday


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
    2 days ago










  • Yeah, right before the while loop.
    – orgee
    2 days ago










  • 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
    2 days ago







  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    2 days ago










  • 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
    2 days ago















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 yesterday


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
    2 days ago










  • Yeah, right before the while loop.
    – orgee
    2 days ago










  • 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
    2 days ago







  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    2 days ago










  • 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
    2 days ago













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 2 days ago









Rabbid76

29.4k112742




29.4k112742










asked 2 days ago









orgee

112




112




put on hold as off-topic by Nicol Bolas, derhass, Rabbid76, EdChum, Shiladitya yesterday


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 yesterday


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
    2 days ago










  • Yeah, right before the while loop.
    – orgee
    2 days ago










  • 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
    2 days ago







  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    2 days ago










  • 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
    2 days ago













  • 1




    Did you glUseProgram before glUniform4f?
    – Rabbid76
    2 days ago










  • Yeah, right before the while loop.
    – orgee
    2 days ago










  • 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
    2 days ago







  • 1




    Do you glLinkProgram before glGetUniformLocation?
    – Rabbid76
    2 days ago










  • 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
    2 days ago








1




1




Did you glUseProgram before glUniform4f?
– Rabbid76
2 days ago




Did you glUseProgram before glUniform4f?
– Rabbid76
2 days ago












Yeah, right before the while loop.
– orgee
2 days ago




Yeah, right before the while loop.
– orgee
2 days ago












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
2 days ago





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
2 days ago





1




1




Do you glLinkProgram before glGetUniformLocation?
– Rabbid76
2 days ago




Do you glLinkProgram before glGetUniformLocation?
– Rabbid76
2 days ago












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
2 days ago





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
2 days ago


















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands