/* Two figures, one with smooth shading and one with flat. Written by Scott D. Anderson scott.anderson@acm.org Fall 2003 */ #include #include const int S = 8; // slices and stacks void display(void) { twDisplayInit(); twCamera(); GLfloat lightPos[] = { 2, 2, 2, 1 }; twGrayLight(GL_LIGHT0,lightPos,0.2,0.8,0.8); glEnable(GL_LIGHTING); twTriple cornflower = {100.0/255, 149.0/255, 237.0/255}; twColor(cornflower, 0.7, 10); glShadeModel(GL_FLAT); glPushMatrix(); glTranslatef(-1,0,0); glutSolidSphere(0.9,S,S); glPopMatrix(); glShadeModel(GL_SMOOTH); glPushMatrix(); glTranslatef(+1,0,0); glutSolidSphere(0.9,S,S); glPopMatrix(); glFlush(); glutSwapBuffers(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); twInitWindowSize(500,300); glutCreateWindow(argv[0]); const float SIZE = 0.7; twBoundingBox(-2*SIZE,+2*SIZE,-SIZE,+SIZE,-SIZE,+SIZE); // a lie, to get us closer twMainInit(); glutDisplayFunc(display); glutMainLoop(); return 0; }