apapaxionga
04-02-2011, 08:42 PM
i wrote a simple shader, in the vertex shader ,i declare a variable: in vect4 color;
i use it like that gl_FrontColor = color;
However , i want to change the value of color, so i wrote
the following code ,but it does not change the color to red.
why???can someone explain this to me ?
void Shader::init(const char *vsFile, const char *fsFile)
{
....;
glShaderSource(...);
glCompileShader(...);
glAttachShader(...);
.....;
GLfloat c[]={1.0,0.0,0.0,1.0};
GLint loc;
loc=glGetAttribLocation(shader_id,"color");
glVertexAttrib3fv(loc,c);
glBindAttribLocation(shader_id,loc,"color");
glLinkProgram(shader_id);
}
i use it like that gl_FrontColor = color;
However , i want to change the value of color, so i wrote
the following code ,but it does not change the color to red.
why???can someone explain this to me ?
void Shader::init(const char *vsFile, const char *fsFile)
{
....;
glShaderSource(...);
glCompileShader(...);
glAttachShader(...);
.....;
GLfloat c[]={1.0,0.0,0.0,1.0};
GLint loc;
loc=glGetAttribLocation(shader_id,"color");
glVertexAttrib3fv(loc,c);
glBindAttribLocation(shader_id,loc,"color");
glLinkProgram(shader_id);
}