If the material is purely green(diffuse) and
the diffuse light source is purely red,
Is the material shown black(R=G=B=0)?
But… the material was shown gray(R=G=B not equal 0).
Why?
The source code is following…
GLfloat diffuseLight[] = { 1.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightPos[] = { -50.f, 50.0f, 100.0f, 1.0f };
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_DIFFUSE);
glClearColor(0.0f, 0.0f, 0.0f,1.0f);
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
…
glColor3ub((GLubyte)0,(GLubyte)255,(GLubyte)0);
glBegin(GL_POLYGON);
for(ff = -bound ; ff <= bound ; ff += gridSize)
{
::glVertex3f(0, ff, bound);
::glVertex3f(0, ff, -bound);
::glVertex3f(0, bound , ff);
::glVertex3f(0, -bound , ff);
}
glEnd();