/* Demonstrates the phases of the moon, by looking at it from different directions. It uses distant lighting and a sphere. Written by Scott D. Anderson scott.anderson@acm.org Fall 2004 */ #include #include #include void display(void) { // twDisplayInit(100/255.0,149/255.0,237/255.0); twDisplayInit(0,0,0); twCamera(); GLfloat sunDir[] = {1, 0, 0, 0}; twTriple black = {0,0,0}; twTriple sunLight = {1,1,1}; glLightfv(GL_LIGHT0, GL_POSITION, sunDir); glLightfv(GL_LIGHT0, GL_AMBIENT, black); glLightfv(GL_LIGHT0, GL_DIFFUSE, sunLight); glLightfv(GL_LIGHT0, GL_SPECULAR, sunLight); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glShadeModel(GL_SMOOTH); twAmbient(0); glPushMatrix(); twTriple moonColor = {0.99, 0.99, 0.99}; twColor(moonColor,0.0,1); // the moon is *not* shiny glutSolidSphere(1,30,30); glPopMatrix(); glFlush(); glutSwapBuffers(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); twInitWindowSize(500,500); glutCreateWindow(argv[0]); glutDisplayFunc(display); twBoundingBox(-1,1,-1,1,-1,1); twMainInit(); glutMainLoop(); return 0; }