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?
opengl
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
add a comment |
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?
opengl
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
1
Did youglUseProgrambeforeglUniform4f?
– Rabbid76
2 days ago
Yeah, right before the while loop.
– orgee
2 days ago
Are you also callingglUniform4fbefore the while loop? Note that the currently attached program must beshader_programfor you to be able to set the uniform for it.
– wdc
2 days ago
1
Do youglLinkProgrambeforeglGetUniformLocation?
– 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
add a comment |
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?
opengl
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
opengl
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
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
1
Did youglUseProgrambeforeglUniform4f?
– Rabbid76
2 days ago
Yeah, right before the while loop.
– orgee
2 days ago
Are you also callingglUniform4fbefore the while loop? Note that the currently attached program must beshader_programfor you to be able to set the uniform for it.
– wdc
2 days ago
1
Do youglLinkProgrambeforeglGetUniformLocation?
– 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
add a comment |
1
Did youglUseProgrambeforeglUniform4f?
– Rabbid76
2 days ago
Yeah, right before the while loop.
– orgee
2 days ago
Are you also callingglUniform4fbefore the while loop? Note that the currently attached program must beshader_programfor you to be able to set the uniform for it.
– wdc
2 days ago
1
Do youglLinkProgrambeforeglGetUniformLocation?
– 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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
Did you
glUseProgrambeforeglUniform4f?– Rabbid76
2 days ago
Yeah, right before the while loop.
– orgee
2 days ago
Are you also calling
glUniform4fbefore the while loop? Note that the currently attached program must beshader_programfor you to be able to set the uniform for it.– wdc
2 days ago
1
Do you
glLinkProgrambeforeglGetUniformLocation?– 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