Original Post
Hi,
I'm trying to move to using the new opengl layout qualifiers. I almost got everything working, however I ran into a small problem.
When I add the overlay_color uniform, I can't set it using the glUniform3fv(), and I don't know why. All the other uniforms, attributes, samplers can be set, except this one... The shader still compiles, links and validates successfully, and no warning is shown that would indicate anything.
When I try to set the overlay_color (using glUniform3fv) I get GL_INVALID_OPERATION. I checked the specs, but I can't figure out what I'm missing, because:
-the program object is set, and valid
-the variable's size matches the glUniform function
-the location (I think) is valid, and not -1
-the count is 1
here's the shader:
here's how I'm passing the values:
I'm trying to move to using the new opengl layout qualifiers. I almost got everything working, however I ran into a small problem.
When I add the overlay_color uniform, I can't set it using the glUniform3fv(), and I don't know why. All the other uniforms, attributes, samplers can be set, except this one... The shader still compiles, links and validates successfully, and no warning is shown that would indicate anything.
When I try to set the overlay_color (using glUniform3fv) I get GL_INVALID_OPERATION. I checked the specs, but I can't figure out what I'm missing, because:
-the program object is set, and valid
-the variable's size matches the glUniform function
-the location (I think) is valid, and not -1
-the count is 1
here's the shader:
[ vertex shader ]
#version 420 core
layout(location=0) uniform mat4 mvp;
layout(location=0) in vec4 in_vertex;
layout(location=5) in vec2 in_texture;
out cross_shader_data
{
vec2 tex_coord;
} o;
out vec4 color;
void main()
{
o.tex_coord = in_texture;
gl_Position = mvp * in_vertex;
}
[ pixel shader ]
#version 420 core
layout(location=1,binding=0) uniform sampler2D texture0;
layout(location=2) uniform vec3 overlay_color;
in cross_shader_data
{
vec2 tex_coord;
} i;
out vec4 color;
void main()
{
color = texture(texture0, i.tex_coord) + vec4(overlay_color, 1);
}
here's how I'm passing the values:
glUseProgram( this->shader );
vec3 overlay_color = {{ 1, 0, 0 }};
glUniform3fv( 2, 1, &overlay_color.v[0] );
glUniformMatrix4fv( 0, 1, false,
&o->ppl->get_model_view_projection_matrix( o->ppl ).m[0].v[0] );