#include #include static GLfloat light0_position[] = {2.0, 8.0, 2.0, 0.0}; GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat mat_shininess[] = {50.0}; GLfloat mat_amb_diff_red[] = {1.0, 0.0, 0.0, 1.0}; GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0}; GLfloat light_ambient[] = {0.15, 0.15, 0.15}; GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; void init () { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } void display (void) { glClear(GL_COLOR_BUFFER_BIT); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_amb_diff_red); glLoadIdentity(); gluLookAt(2.0, 4.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); glScalef(x, y, z); glutSolidTeapot(1.0); glPopMatrix(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); /* define the projection */ gluPerspective(45.0, (GLfloat) w / (GLfloat) h, 2.0, 20.0); glMatrixMode(GL_MODELVIEW); } int main(int argc, char** argv) { glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition (0, 0); glutInitWindowSize(400, 400); glutCreateWindow ("Scaling Transformation"); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; }