/************************************************************************** you can use this code as it is but you would have to declare some variables and define them. 1. GLfloat light0pos[4]; // this specifies the location of the light. set it to the coordinates of the center of the sun. you can set the fourth coordinate to 1. 2. for all the 3D you just need to specify a color and a normal vector if you want to see the effect of lighting. glut automatically generates normal for the objects that it generates. for the polygonal model, you have specify the face normal for each face. For example: glBegin(GL_POLYGON); glNormal3f(); //the normal vector specified using the three coordinates glVertex3f(...); . . . glVertex3f(...); //vertices of a planar polygon glEnd(); you can compute the normal by taking the cross product of any two vectors on the polygon (if A,B,C are three vertices of the polygon then two vectors on the polygon are A-B and C-B). Make sure that the normal is an outward pointing normal. **************************************************************************/ { /* this turns on lighting */ glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, light0pos); /* This makes it easier for you to provide light */ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }