You are on page 1of 1

C:\Users\madar\Documents\Visual Studio 2010\Projects\prgm6\prgm6\prg6.

cpp 1
1 #include<gl/glut.h>
2 void obj(double tx,double ty,double tz,double sx,double sy,double sz)
3 {
4 glRotated(50,0,1,0);
5 glRotated(10,-1,0,0);
6 glRotated(11.7,0,0,-1);
7 glTranslated(tx,ty,tz);
8 glScaled(sx,sy,sz);
9 glutSolidCube(1);
10 glLoadIdentity();
11 }
12 void display()
13 {
14 glViewport(0,0,700,700);
15 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
16 obj(0,0,0.5,1,1,0.04); // three walls
17 obj(0,-0.5,0,1,0.04,1);
18 obj(-0.5,0,0,0.04,1,1);
19 obj(0,-0.3,0,0.02,0.2,0.02); // four table legs
20 obj(0,-0.3,-0.4,0.02,0.2,0.02);
21 obj(0.4,-0.3,0,0.02,0.2,0.02);
22 obj(0.4,-0.3,-0.4,0.02,0.2,0.02);
23 obj(0.2,-0.18,-0.2,0.6,0.02,0.6); // table top
24 glRotated(50,0,1,0);
25 glRotated(10,-1,0,0);
26 glRotated(11.7,0,0,-1);
27 glTranslated(0.3,-0.1,-0.3);
28 glutSolidTeapot(0.09);
29 glFlush();
30 glLoadIdentity();
31 }
32 void main()
33 {
34 float ambient[]={1,1,1,1};
35 float light_pos[]={27,80,2,3};
36 glutInitWindowSize(700,700);
37 glutCreateWindow("scene");
38 glutDisplayFunc(display);
39 glEnable(GL_LIGHTING);
40 glEnable(GL_LIGHT0);
41 glMaterialfv(GL_FRONT,GL_AMBIENT,ambient);
42 glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
43 glEnable(GL_DEPTH_TEST);
44 glutMainLoop();
45 }

You might also like