Hello,
I have found some very unexpected behaviour and I am wondering if there something I am missing or it is in fact so ? I am using the following code to install a shader and then render two QUADS, each with a different ambient color.
glUseProgramObjectARB(mProgram);
float mat_ambient1[] = {0.0f, 0.0f, 0.7f, 1.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,mat_ambient1);
glBegin(GL_QUADS);
glVertex3f(0, 0, 0);
glVertex3f(100, 0, 0);
glVertex3f(100, 100, 0);
glVertex3f(0, 100, 0);
glEnd();
float mat_ambient2[] = {0.7f, 0.0f, 0.0f, 1.0f};
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient2);
glBegin(GL_QUADS);
glVertex3f(-100, -100, 0);
glVertex3f(0, -100, 0);
glVertex3f(0, 0, 0);
glVertex3f(-100, 0, 0);
glEnd();
All that the shaders do is
gl_Position = ftransform();
and
gl_FragColor = gl_FrontMaterial.ambient;
It turns out that both QUADS are blue (i.e. mat_ambient1) allthough I changed the color to red for the second one. Does the shader somehow cash the gl_FrontMaterial. If I insert another
glUseProgramObjectARB(mProgram);
just before the declaration of mat_ambient2 then the second quad becomes red. Am I missing something fundamentel here? Do I have to call glUseProgramObjectARB every time I change the material?
Cheers
Jochen