It works on some video cards, but on some others, a previously used color is also used.
I found that specifying glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); solves the problem.
And also, if I call glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); before calling glEnable(GL_COLOR_MATERIAL);, the result is correct.
Is is something known that one must call glColorMaterial BEFORE enabling GL_COLOR_MATERIAL ?
And why is-it card dependant ?
Yes, glColorMaterial has to be called before calling glEnable(GL_COLOR_MATERIAL). If you don’t, the behaviour is not specified. Some drivers/cards just happen to not care about the order, so you sometimes get away with it.
For instance,
calling
ColorMaterial(FRONT, AMBIENT)
while COLOR MATERIAL is enabled sets the front material acm to the value of the
current color.
Also there’s a data flow diagram on the next page that seems a very clear description of what is happening. Also there’s no mention about an “active” copy of the state like in the VBO spec.
This sounds to me that glColorMaterial should work after GL_COLOR_MATERIAL is enabled, it’s very well defined what should happen. Could be a driver bug… Or am I misinterpreting the spec here?
Originally posted by memfr0b: Yes, glColorMaterial has to be called before calling glEnable(GL_COLOR_MATERIAL). If you don’t, the behaviour is not specified. Some drivers/cards just happen to not care about the order, so you sometimes get away with it.
Wrong. Of couse it is specified and the default is (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE).