How to get working OpenGL color matrix transformations?
I changed the sample program that just draws a triangle, and added the color matrix code to see if I can change the colors of the triangle, but it does not work.
static float theta = 0.0f; glClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); glClearDepth(1.0); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef( theta, 0.0f, 0.0f, 1.0f ); glMatrixMode(GL_COLOR); GLfloat rgbconversion[16] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; glLoadMatrixf(rgbconversion); glMatrixMode(GL_MODELVIEW); glBegin( GL_TRIANGLES ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 1.0f , 0.5f); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex3f( 0.87f, -0.5f, 0.5f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex3f( -0.87f, -0.5f, 0.5f ); glEnd(); glPopMatrix();
As far as I can tell, the color matrix I am loading should change the triangle to black, but it doesn't seem to work. Is something missing?