/* * Copyright (c) 1993-1997, Silicon Graphics, Inc. * ALL RIGHTS RESERVED * * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. */ /* * smooth.c * This program demonstrates smooth shading. * A smooth shaded polygon is drawn in a 3-D projection. */ #include #include void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); } void triangle(void) { glBegin (GL_TRIANGLES); glColor3f (1.0, 0.0, 0.0); glVertex3f (5.0, 5.0, 0.0); glColor3f (0.0, 1.0, 0.0); glVertex3f (25.0, 5.0, 0.0); glColor3f (0.0, 0.0, 1.0); glVertex3f (5.0, 25.0, 0.0); glEnd(); } void display(void) { glMatrixMode (GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, 1.0, 1.0, 100.0); glMatrixMode (GL_MODELVIEW); glLoadIdentity(); gluLookAt (10.0, 10.0, 30.0, 10.0, 10.0, 0.0, 0.0, 1.0, 0.0); glClear (GL_COLOR_BUFFER_BIT); triangle (); glFlush (); } void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); } /* ARGSUSED1 */ void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: /* escape key */ exit(0); break; } } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutMainLoop(); return 0; }