Hi! I want to initialize my uniform variable in GLSL with a default value, but the program give me an error when I run it:
Fragment code GLSL
uniform vec3 Color = vec3(1.0,0.0,0.0);
out vec3 out_Color;
void main(void){
out_Color = Color;
}
If I the variable "Color" isn´t a uniform variable, the program works. I need that Color is uniform to change his value from a class.
When I load the material I call this method:
void Color_mat::Load(void)
{
shader = getParent()->getEngine()->content.Load("Shaders/ColorShader.glsl");
Material::Load();
ColorUniformLocation = glGetUniformLocation(shader->ID, "Color");
ExitOnGLError("ERROR: Could not get the Color uniform location");
}
And When I draw, i call this method to start drawing the objects:
void Color_mat::Prepare3dDraw(glm::mat4 ModelMatrix)
{
Material::Prepare3dDraw(ModelMatrix);
glUniform3f(ColorUniformLocation, color.x, color.y, color.z);
ExitOnGLError("ERROR: Could not set the color");
}