I am having problems with using lighting. I am drawing a simple 3x3 image that is 3-dimensional. I have successfully drawn it as a wireframe object but when I try to draw it as GL_POLYGON I get a bright white object. I have a sample program that my friend gave me that successfully lights an icosahedron in another program. He said I could use his lighting method in my program to draw the image. Unfortunately, his lighting produces this bright white object for me. Here is what I do to do my lighting:
In an init function:
mat_specular = 1.0; mat_specular = 1.0; mat_specular = 1.0; mat_specular = 0.15; mat_shininess = 50.0; mat_solid = 0.75; mat_solid = 0.75; mat_solid = 0.0; mat_solid = 1.0; /* These are properties of light. */ position = 10.0; position = 10.0; position = 5.0; position = 0.0; light_diffuse = 1.0; light_diffuse = 1.0; light_diffuse = 1.0; light_diffuse = 1.0; light_specular = 1.0; light_specular = 1.0; light_specular = 1.0; light_specular = 1.0; glMaterialfv( GL_FRONT, GL_DIFFUSE, mat_solid ); glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular ); glMaterialfv( GL_FRONT, GL_SHININESS, mat_shininess ); glLightfv( GL_LIGHT0, GL_POSITION, position ); glLightfv( GL_LIGHT0, GL_DIFFUSE, light_diffuse ); glLightfv( GL_LIGHT0, GL_SPECULAR, light_specular ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_DEPTH_TEST ); glEnable( GL_NORMALIZE ); //glEnable( GL_CULL_FACE ); glFrontFace(GL_CW);
When I draw my polygons, I do this:
calcNormal( v, normal ); glBegin( GL_POLYGON ); glNormal3fv( normal ); glVertex3fv( v ); glVertex3fv( v ); glVertex3fv( v ); glEnd( );
This code is in a loop to draw multiple polygons. Why am I getting bright white objects all the time and not a shaded yellow-ish object like in my sample program. The sample program did not color the polygons at any time. Thanks for your help!!!