Advertisement
sajid006

Opengl Project SemiFinal

Jun 9th, 2021
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 45.79 KB | None | 0 0
  1.  
  2. #include<GL/gl.h>
  3. #include <GL/glu.h>
  4. #include <GL/glut.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <windows.h>
  8. #include<math.h>
  9. #include "BmpLoader.h"
  10. const int width = 1000;
  11. const int height = 1000;
  12.  
  13. GLfloat eyeX = 0;
  14. GLfloat eyeY = 6;
  15. GLfloat eyeZ = -13;
  16.  
  17. GLfloat lookX = 0;
  18. GLfloat lookY = 5;
  19. GLfloat lookZ = 0;
  20.  
  21. GLfloat alpha = 0.0, theta = 0.0, axis_x=0.0, axis_y=0.0, f_spin=0.0;
  22. GLboolean bRotate = false, uRotate = false;
  23.  
  24. float da[8]= {0,0,0,0,0,1,1,1};
  25. bool l_on=true;
  26. bool press1 = false;
  27. bool press2 = false;
  28. bool press4 = false;
  29. bool flagRot = false;
  30. float rot = 0;
  31. unsigned int ID;
  32.  
  33. double spin=1.0;
  34. bool isrot=1;
  35.  
  36. float px=0,py=30,pz=30,spot_cutoff = 30;
  37.  
  38. static GLfloat v_cube[8][3] =
  39. {
  40.     {0,0,0},
  41.     {0,0,1},
  42.     {0,1,0},
  43.     {0,1,1},
  44.  
  45.     {1,0,0},
  46.     {1,0,1},
  47.     {1,1,0},
  48.     {1,1,1}
  49. };
  50.  
  51. static GLubyte c_ind[6][4] =
  52. {
  53.     {3,1,5,7},  //front
  54.     {6,4,0,2},  //back
  55.     {2,3,7,6},  //top
  56.     {1,0,4,5},  //bottom
  57.     {7,5,4,6},  //right
  58.     {2,0,1,3}   //left
  59. };
  60.  
  61. static void getNormal3p(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2, GLfloat x3, GLfloat y3, GLfloat z3)
  62. {
  63.     GLfloat Ux, Uy, Uz, Vx, Vy, Vz, Nx, Ny, Nz;
  64.  
  65.     Ux = x2-x1;
  66.     Uy = y2-y1;
  67.     Uz = z2-z1;
  68.  
  69.     Vx = x3-x1;
  70.     Vy = y3-y1;
  71.     Vz = z3-z1;
  72.  
  73.     Nx = Uy*Vz - Uz*Vy;
  74.     Ny = Uz*Vx - Ux*Vz;
  75.     Nz = Ux*Vy - Uy*Vx;
  76.  
  77.     glNormal3f(Nx,Ny,Nz);
  78. }
  79.  
  80. void set_material(float R=0.5, float G=0.5, float B=0.5, bool e=false, bool l = false)
  81. {
  82.     GLfloat mat_no[] = {0,0,0, 1.0};
  83.     GLfloat mat_amb[] = {R,G,B,1};
  84.     GLfloat mat_diff[] = {R,G,B,1};
  85.     GLfloat mat_spec[] = {1,1,1,1};
  86.     GLfloat mat_sh[] = {30};
  87.  
  88.     GLfloat mat_em[] = {1,1,1,1};
  89.  
  90.     glMaterialfv(GL_FRONT, GL_AMBIENT, mat_amb);
  91.     glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diff);
  92.     glMaterialfv(GL_FRONT, GL_SPECULAR, mat_spec);
  93.     glMaterialfv(GL_FRONT, GL_SHININESS, mat_sh);
  94.  
  95.     if(e && l)
  96.     {
  97.         glMaterialfv(GL_FRONT, GL_EMISSION, mat_em);
  98.     }
  99.     else
  100.     {
  101.         glMaterialfv(GL_FRONT, GL_EMISSION, mat_no);
  102.     }
  103. }
  104.  
  105.  
  106. void cube2(float R=0.5, float G=0.5, float B=0.5, bool e=false, float alpha=1)
  107. {
  108.  
  109.     GLfloat m_no[] = {0, 0, 0, 1.0};
  110.     GLfloat m_amb[] = {R,G,B,1};
  111.     GLfloat m_diff[] = {R,G,B,1};
  112.     GLfloat m_spec[] = {1,1,1,1};
  113.     GLfloat m_sh[] = {30};
  114.  
  115.     GLfloat m_em[] = {1,1,1,1};
  116.  
  117.     glMaterialfv(GL_FRONT, GL_AMBIENT, m_amb);
  118.     glMaterialfv(GL_FRONT, GL_DIFFUSE, m_diff);
  119.     glMaterialfv(GL_FRONT, GL_SPECULAR, m_spec);
  120.     glMaterialfv(GL_FRONT, GL_SHININESS, m_sh);
  121.  
  122.     if(e & l_on)
  123.         glMaterialfv(GL_FRONT, GL_EMISSION, m_em);
  124.     else
  125.         glMaterialfv(GL_FRONT, GL_EMISSION, m_no);
  126.  
  127.     glBegin(GL_QUADS);
  128.     for (GLint i = 0; i <6; i++)
  129.     {
  130.         getNormal3p(v_cube[c_ind[i][0]][0], v_cube[c_ind[i][0]][1], v_cube[c_ind[i][0]][2],
  131.                     v_cube[c_ind[i][1]][0], v_cube[c_ind[i][1]][1], v_cube[c_ind[i][1]][2],
  132.                     v_cube[c_ind[i][2]][0], v_cube[c_ind[i][2]][1], v_cube[c_ind[i][2]][2]);
  133.  
  134.         for (GLint j=0; j<4; j++)
  135.         {
  136.             glVertex3fv(&v_cube[c_ind[i][j]][0]);
  137.         }
  138.     }
  139.     glEnd();
  140. }
  141.  
  142. void cube(float R=0.5, float G=0.5, float B=0.5, bool e=false, bool l = false)
  143. {
  144.  
  145.     set_material(R,G,B,l);
  146.  
  147.     glBegin(GL_QUADS);
  148.     for (GLint i = 0; i <6; i++)
  149.     {
  150.         getNormal3p(v_cube[c_ind[i][0]][0], v_cube[c_ind[i][0]][1], v_cube[c_ind[i][0]][2],
  151.                     v_cube[c_ind[i][1]][0], v_cube[c_ind[i][1]][1], v_cube[c_ind[i][1]][2],
  152.                     v_cube[c_ind[i][2]][0], v_cube[c_ind[i][2]][1], v_cube[c_ind[i][2]][2]);
  153.  
  154.         glTexCoord2f(0,1);
  155.         glVertex3fv(&v_cube[c_ind[i][0]][0]);
  156.         glTexCoord2f(0,0);
  157.         glVertex3fv(&v_cube[c_ind[i][1]][0]);
  158.         glTexCoord2f(1,0);
  159.         glVertex3fv(&v_cube[c_ind[i][2]][0]);
  160.         glTexCoord2f(1,1);
  161.         glVertex3fv(&v_cube[c_ind[i][3]][0]);
  162.     }
  163.     glEnd();
  164. }
  165.  
  166. void axes()
  167. {
  168.     float length = 10;
  169.     float width = 0.3;
  170.  
  171.     // X-axis
  172.     glPushMatrix();
  173.     glTranslatef(length/2,0,0);
  174.     glScalef(length,width,width);
  175.     glTranslatef(-0.5,-0.5,-0.5);
  176.     cube(0.8,0.1,0.1);
  177.     glPopMatrix();
  178.  
  179.     // Y-axis
  180.     glPushMatrix();
  181.     glTranslatef(0,length/2,0);
  182.     glScalef(width,length,width);
  183.     glTranslatef(-0.5,-0.5,-0.5);
  184.     cube(0.1,0.8,0.1);
  185.     glPopMatrix();
  186.  
  187.     // Z-axis
  188.     glPushMatrix();
  189.     glTranslatef(0,0,length/2);
  190.     glScalef(width,width,length);
  191.     glTranslatef(-0.5,-0.5,-0.5);
  192.     cube(0.1,0.1,0.8);
  193.     glPopMatrix();
  194. }
  195.  
  196. void rodshape1(float x,float y,float z)
  197. {
  198.     float t_length = 6;
  199.     float t_width = 0.5;
  200.  
  201.     glPushMatrix();
  202.     //glTranslatef(-14.5,7,0);
  203.     glTranslatef(x,y,z);
  204.  
  205.     glPushMatrix();
  206.     glScalef(t_width,t_width,t_length);
  207.     glTranslatef(-0.5,0,-0.5);
  208.     cube(1,1,1,true,press1);
  209.     glPopMatrix();
  210.  
  211.     glPushMatrix();
  212.     glTranslatef(0,0,t_length/2+t_width/2);
  213.     glScalef(t_width,t_width,t_width);
  214.     glTranslatef(-0.5,0,-0.5);
  215.     cube(0.2,0.2,0.2);
  216.     glPopMatrix();
  217.  
  218.     glPushMatrix();
  219.     glTranslatef(0,0,-t_length/2-t_width/2);
  220.     glScalef(t_width,t_width,t_width);
  221.     glTranslatef(-0.5,0,-0.5);
  222.     cube(0.2,0.2,0.2);
  223.     glPopMatrix();
  224.  
  225.     glPopMatrix();
  226.  
  227. }
  228.  
  229. void rodshape2(float x, float y, float z)
  230. {
  231.     float t_length = 6;
  232.     float t_width = 0.5;
  233.  
  234.     glPushMatrix();
  235.     //glTranslatef(-14.5,7,0);
  236.     glTranslatef(x,y,z);
  237.  
  238.     glPushMatrix();
  239.     glScalef(t_width,t_width,t_length);
  240.     glTranslatef(-0.5,0,-0.5);
  241.     cube(1,1,1,true,press2);
  242.     glPopMatrix();
  243.  
  244.     glPushMatrix();
  245.     glTranslatef(0,0,t_length/2+t_width/2);
  246.     glScalef(t_width,t_width,t_width);
  247.     glTranslatef(-0.5,0,-0.5);
  248.     cube(0.2,0.2,0.2);
  249.     glPopMatrix();
  250.  
  251.     glPushMatrix();
  252.     glTranslatef(0,0,-t_length/2-t_width/2);
  253.     glScalef(t_width,t_width,t_width);
  254.     glTranslatef(-0.5,0,-0.5);
  255.     cube(0.2,0.2,0.2);
  256.     glPopMatrix();
  257.  
  258.     glPopMatrix();
  259.  
  260. }
  261.  
  262. void spotlightshape(float x,float y, float z)
  263. {
  264.     float s_height = 0.25;
  265.     float s_width = 2;
  266.     float s_length = 2;
  267.  
  268.     glPushMatrix();
  269.     glTranslatef(x,y,z);
  270.     /*
  271.     glPushMatrix();
  272.     glScalef(s_width,s_height,s_length);
  273.     glTranslatef(-0.5,0,-0.5);
  274.     cube(1,1,1);
  275.     glPopMatrix();
  276.     */
  277.     glPushMatrix();
  278.     glScalef(s_width,s_height,s_length);
  279.     glTranslatef(-0.5,0,-0.5);
  280.     cube(1,1,1,true,press4);
  281.     glPopMatrix();
  282.  
  283.     glPopMatrix();
  284.  
  285. }
  286.  
  287. void door(float x,float y,float z,int id,float sx=5,float sy=10)
  288. {
  289.     glEnable(GL_TEXTURE_2D);
  290.     glBindTexture(GL_TEXTURE_2D,19);
  291.     glPushMatrix();
  292.  
  293.     if(da[id]==0)
  294.     {
  295.         glTranslatef(x,y,z);
  296.         //glRotatef(da[id],0,1,0);
  297.         glScalef(sx,sy,0.2);
  298.     }
  299.     else
  300.     {
  301.  
  302.         glTranslatef(x+(sx/2.0),y,z+(sx/2.0));
  303.         glScalef(0.2,sy,sx);
  304.     }
  305.     glTranslatef(-0.5,-0.5,-0.5);
  306.     cube(1,1,1);
  307.     glPopMatrix();
  308.     glDisable(GL_TEXTURE_2D);
  309. }
  310.  
  311.  
  312. void light1(float x,float y,float z)
  313. {
  314.     //light
  315.     GLfloat l1_no[] = {0, 0, 0, 1.0};
  316.     GLfloat l1_amb[] = {0.1, 0.1, 0.1, 1.0};
  317.     GLfloat l1_dif[] = {1,1,0,1};
  318.     GLfloat l1_spec[] = {1,1,0,1};
  319.     GLfloat l1_pos[] = {x,y,z,1.0};
  320.     //GLfloat l_pos[] = {-14.5,-7,10,1.0};
  321.  
  322.     glEnable(GL_LIGHT0);
  323.  
  324.     if(press1)
  325.     {
  326.         glLightfv(GL_LIGHT0, GL_AMBIENT, l1_amb);
  327.     }
  328.     else
  329.     {
  330.         glLightfv(GL_LIGHT0, GL_AMBIENT, l1_no);
  331.     }
  332.     if(press1)
  333.     {
  334.         glLightfv(GL_LIGHT0, GL_DIFFUSE, l1_dif);
  335.     }
  336.     else
  337.     {
  338.         glLightfv(GL_LIGHT0, GL_DIFFUSE, l1_no);
  339.     }
  340.     if(press1)
  341.     {
  342.         glLightfv(GL_LIGHT0, GL_SPECULAR, l1_spec);
  343.     }
  344.     else
  345.     {
  346.         glLightfv(GL_LIGHT0, GL_SPECULAR, l1_no);
  347.     }
  348.  
  349.  
  350.     glLightfv(GL_LIGHT0, GL_POSITION, l1_pos);
  351. }
  352.  
  353. void light2(float x,float y, float z)
  354. {
  355.     //light
  356.     GLfloat l2_no[] = {0, 0, 0, 1.0};
  357.     GLfloat l2_amb[] = {0.1, 0.1, 0.1, 1.0};
  358.     GLfloat l2_dif[] = {1,1,1,1};
  359.     GLfloat l2_spec[] = {1,1,1,1};
  360.     //GLfloat l_pos[] = {-14.5,7,0,1.0};
  361.     GLfloat l2_pos[] = {x,y,z,1.0};
  362.  
  363.     glEnable(GL_LIGHT1);
  364.  
  365.     if(press2)
  366.     {
  367.         glLightfv(GL_LIGHT1, GL_AMBIENT, l2_amb);
  368.     }
  369.     else
  370.     {
  371.         glLightfv(GL_LIGHT1, GL_AMBIENT, l2_no);
  372.     }
  373.     if(press2)
  374.     {
  375.         glLightfv(GL_LIGHT1, GL_DIFFUSE, l2_dif);
  376.     }
  377.     else
  378.     {
  379.         glLightfv(GL_LIGHT1, GL_DIFFUSE, l2_no);
  380.     }
  381.     if(press2)
  382.     {
  383.         glLightfv(GL_LIGHT1, GL_SPECULAR, l2_spec);
  384.     }
  385.     else
  386.     {
  387.         glLightfv(GL_LIGHT1, GL_SPECULAR, l2_no);
  388.     }
  389.  
  390.     glLightfv(GL_LIGHT1, GL_POSITION, l2_pos);
  391. }
  392.  
  393. void light3(float x,float y, float z)
  394. {
  395.     //light
  396.     GLfloat l3_no[] = {0, 0, 0, 1.0};
  397.     GLfloat l3_amb[] = {0.5, 0.5, 0.5, 1.0};
  398.     GLfloat l3_dif[] = {1,0,1,1};
  399.     GLfloat l3_spec[] = {1,0,1,1};
  400.     GLfloat l3_pos[] = {x,y,z,1.0};
  401.     //GLfloat l_pos[] = {14,-7,10,1.0};
  402.  
  403.     glEnable(GL_LIGHT2);
  404.  
  405.     if(press4)
  406.     {
  407.         glLightfv(GL_LIGHT2, GL_AMBIENT, l3_amb);
  408.     }
  409.     else
  410.     {
  411.         glLightfv(GL_LIGHT2, GL_AMBIENT, l3_no);
  412.     }
  413.     if(press4)
  414.     {
  415.         glLightfv(GL_LIGHT2, GL_DIFFUSE, l3_dif);
  416.     }
  417.     else
  418.     {
  419.         glLightfv(GL_LIGHT2, GL_DIFFUSE, l3_no);
  420.     }
  421.     if(press4)
  422.     {
  423.         glLightfv(GL_LIGHT2, GL_SPECULAR, l3_spec);
  424.     }
  425.     else
  426.     {
  427.         glLightfv(GL_LIGHT2, GL_SPECULAR, l3_no);
  428.     }
  429.  
  430.     glLightfv(GL_LIGHT2, GL_POSITION, l3_pos);
  431.  
  432.     // spot light extra
  433.     GLfloat l3_spt[] = {0,0,-1,1};
  434.     GLfloat spt_ct[] = {spot_cutoff};
  435.     glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, l3_spt);
  436.     glLightfv(GL_LIGHT2, GL_SPOT_CUTOFF, spt_ct);
  437.  
  438. }
  439. void DrawCircle(float cx, float cy, float r, int num_segments)
  440. {
  441.     glBegin(GL_TRIANGLE_FAN);
  442.     for(int ii = 0; ii < num_segments; ii++)
  443.     {
  444.         float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
  445.  
  446.         float x = r * cosf(theta);//calculate the x component
  447.         float y = r * sinf(theta);//calculate the y component
  448.  
  449.         glVertex2f(x + cx, y + cy);//output vertex
  450.  
  451.     }
  452.     glEnd();
  453. }
  454.  
  455.  
  456. static GLfloat v_pyramid[5][3] =
  457. {
  458.     {0.0, 0.0, 0.0},
  459.     {0.0, 0.0, 2.0},
  460.     {2.0, 0.0, 2.0},
  461.     {2.0, 0.0, 0.0},
  462.     {1.0, 4.0, 1.0}
  463. };
  464.  
  465. static GLubyte p_Indices[4][3] =
  466. {
  467.     {4, 1, 2},
  468.     {4, 2, 3},
  469.     {4, 3, 0},
  470.     {4, 0, 1}
  471. };
  472.  
  473. static GLubyte quadIndices[1][4] =
  474. {
  475.     {0, 3, 2, 1}
  476. };
  477.  
  478. static GLfloat colors[5][3] =
  479. {
  480.     {0.0, 0.0, 1.0},
  481.     {0.5, 0.0, 1.0},
  482.     {0.0, 1.0, 0.0},
  483.     {0.0, 1.0, 1.0},
  484.     {0.8, 0.0, 0.0}
  485. };
  486.  
  487. void drawpyramid()
  488. {
  489.     //glDisable(GL_LIGHTING);
  490.     //glColor3f(1,0,0);
  491.     glBegin(GL_TRIANGLES);
  492.     for (GLint i = 0; i <4; i++)
  493.     {
  494.         //glColor3f(colors[i][0],colors[i][1],colors[i][2]);
  495.         getNormal3p(v_pyramid[p_Indices[i][0]][0], v_pyramid[p_Indices[i][0]][1], v_pyramid[p_Indices[i][0]][2],
  496.                     v_pyramid[p_Indices[i][1]][0], v_pyramid[p_Indices[i][1]][1], v_pyramid[p_Indices[i][1]][2],
  497.                     v_pyramid[p_Indices[i][2]][0], v_pyramid[p_Indices[i][2]][1], v_pyramid[p_Indices[i][2]][2]);
  498.  
  499.         glVertex3fv(&v_pyramid[p_Indices[i][0]][0]);
  500.         glVertex3fv(&v_pyramid[p_Indices[i][1]][0]);
  501.         glVertex3fv(&v_pyramid[p_Indices[i][2]][0]);
  502.     }
  503.     glEnd();
  504.  
  505.     glBegin(GL_QUADS);
  506.     for (GLint i = 0; i <1; i++)
  507.     {
  508.         //glColor3f(colors[4][0],colors[4][1],colors[4][2]);
  509.         getNormal3p(v_pyramid[quadIndices[i][0]][0], v_pyramid[quadIndices[i][0]][1], v_pyramid[quadIndices[i][0]][2],
  510.                     v_pyramid[quadIndices[i][1]][0], v_pyramid[quadIndices[i][1]][1], v_pyramid[quadIndices[i][1]][2],
  511.                     v_pyramid[quadIndices[i][2]][0], v_pyramid[quadIndices[i][2]][1], v_pyramid[quadIndices[i][2]][2]);
  512.  
  513.         glVertex3fv(&v_pyramid[quadIndices[i][0]][0]);
  514.         glVertex3fv(&v_pyramid[quadIndices[i][1]][0]);
  515.         glVertex3fv(&v_pyramid[quadIndices[i][2]][0]);
  516.         glVertex3fv(&v_pyramid[quadIndices[i][3]][0]);
  517.     }
  518.     glEnd();
  519.  
  520.  
  521. }
  522.  
  523.  
  524. void building()
  525. {
  526.     ///Building Front Right
  527.     glEnable(GL_TEXTURE_2D);
  528.     glBindTexture(GL_TEXTURE_2D,4);
  529.     glPushMatrix();
  530.     glTranslatef(-25,0,35);
  531.     glScalef(40,40,0.1);
  532.     glTranslatef(-0.5,-0.5,-0.5);
  533.     cube(1,1,1);
  534.     glPopMatrix();
  535.     glDisable(GL_TEXTURE_2D);
  536.     glEnable(GL_TEXTURE_2D);
  537.     glBindTexture(GL_TEXTURE_2D,5);
  538.     glPushMatrix();
  539.     glTranslatef(-25,0,35.1);
  540.     glScalef(40,40,0.1);
  541.     glTranslatef(-0.5,-0.5,-0.5);
  542.     cube(1,1,1);
  543.     glPopMatrix();
  544.     glDisable(GL_TEXTURE_2D);
  545.  
  546.     ///Building Front Left
  547.     glEnable(GL_TEXTURE_2D);
  548.     glBindTexture(GL_TEXTURE_2D,4);
  549.     glPushMatrix();
  550.     glTranslatef(25,0,35);
  551.     glScalef(40,40,0.1);
  552.     glTranslatef(-0.5,-0.5,-0.5);
  553.     cube(1,1,1);
  554.     glPopMatrix();
  555.     glDisable(GL_TEXTURE_2D);
  556.     glEnable(GL_TEXTURE_2D);
  557.     glBindTexture(GL_TEXTURE_2D,5);
  558.     glPushMatrix();
  559.     glTranslatef(25,0,35.1);
  560.     glScalef(40,40,0.1);
  561.     glTranslatef(-0.5,-0.5,-0.5);
  562.     cube(1,1,1);
  563.     glPopMatrix();
  564.     glDisable(GL_TEXTURE_2D);
  565.  
  566.     ///Building Right
  567.     glEnable(GL_TEXTURE_2D);
  568.     glBindTexture(GL_TEXTURE_2D,4);
  569.     glPushMatrix();
  570.     glTranslatef(-45,0,75);
  571.     glScalef(0.1,40,80);
  572.     glTranslatef(-0.5,-0.5,-0.5);
  573.     cube(1,1,1);
  574.     glPopMatrix();
  575.     glDisable(GL_TEXTURE_2D);
  576.     glEnable(GL_TEXTURE_2D);
  577.     glBindTexture(GL_TEXTURE_2D,5);
  578.     glPushMatrix();
  579.     glTranslatef(-44.9,0,75);
  580.     glScalef(0.1,40,80);
  581.     glTranslatef(-0.5,-0.5,-0.5);
  582.     cube(1,1,1);
  583.     glPopMatrix();
  584.     glDisable(GL_TEXTURE_2D);
  585.  
  586.     ///Building Left
  587.     glEnable(GL_TEXTURE_2D);
  588.     glBindTexture(GL_TEXTURE_2D,4);
  589.     glPushMatrix();
  590.     glTranslatef(45,0,75);
  591.     glScalef(0.1,40,80);
  592.     glTranslatef(-0.5,-0.5,-0.5);
  593.     cube(1,1,1);
  594.     glPopMatrix();
  595.     glDisable(GL_TEXTURE_2D);
  596.     glEnable(GL_TEXTURE_2D);
  597.     glBindTexture(GL_TEXTURE_2D,5);
  598.     glPushMatrix();
  599.     glTranslatef(44.9,0,75);
  600.     glScalef(0.1,40,80);
  601.     glTranslatef(-0.5,-0.5,-0.5);
  602.     cube(1,1,1);
  603.     glPopMatrix();
  604.     glDisable(GL_TEXTURE_2D);
  605.  
  606.     ///Building Back Left
  607.     glEnable(GL_TEXTURE_2D);
  608.     glBindTexture(GL_TEXTURE_2D,4);
  609.     glPushMatrix();
  610.     glTranslatef(25,0,115);
  611.     glScalef(40,40,0.1);
  612.     glTranslatef(-0.5,-0.5,-0.5);
  613.     cube(1,1,1);
  614.     glPopMatrix();
  615.     glDisable(GL_TEXTURE_2D);
  616.     glEnable(GL_TEXTURE_2D);
  617.     glBindTexture(GL_TEXTURE_2D,5);
  618.     glPushMatrix();
  619.     glTranslatef(25,0,114.9);
  620.     glScalef(40,40,0.1);
  621.     glTranslatef(-0.5,-0.5,-0.5);
  622.     cube(1,1,1);
  623.     glPopMatrix();
  624.     glDisable(GL_TEXTURE_2D);
  625.  
  626.     ///Building Back Right
  627.     glEnable(GL_TEXTURE_2D);
  628.     glBindTexture(GL_TEXTURE_2D,4);
  629.     glPushMatrix();
  630.     glTranslatef(-25,0,115);
  631.     glScalef(40,40,0.1);
  632.     glTranslatef(-0.5,-0.5,-0.5);
  633.     cube(1,1,1);
  634.     glPopMatrix();
  635.     glDisable(GL_TEXTURE_2D);
  636.     glEnable(GL_TEXTURE_2D);
  637.     glBindTexture(GL_TEXTURE_2D,5);
  638.     glPushMatrix();
  639.     glTranslatef(-25,0,114.9);
  640.     glScalef(40,40,0.1);
  641.     glTranslatef(-0.5,-0.5,-0.5);
  642.     cube(1,1,1);
  643.     glPopMatrix();
  644.     glDisable(GL_TEXTURE_2D);
  645.  
  646.     ///Inside Front Left
  647.     glEnable(GL_TEXTURE_2D);
  648.     glBindTexture(GL_TEXTURE_2D,5);
  649.     glPushMatrix();
  650.     glTranslatef(5,0,45);
  651.     glScalef(0.1,40,20);
  652.     glTranslatef(-0.5,-0.5,-0.5);
  653.     cube(1,1,1);
  654.     glPopMatrix();
  655.     glDisable(GL_TEXTURE_2D);
  656.  
  657.     ///Inside Front Right
  658.     glEnable(GL_TEXTURE_2D);
  659.     glBindTexture(GL_TEXTURE_2D,5);
  660.     glPushMatrix();
  661.     glTranslatef(-5,0,45);
  662.     glScalef(0.1,40,20);
  663.     glTranslatef(-0.5,-0.5,-0.5);
  664.     cube(1,1,1);
  665.     glPopMatrix();
  666.     glDisable(GL_TEXTURE_2D);
  667.  
  668.     ///Inside Back Left
  669.     glEnable(GL_TEXTURE_2D);
  670.     glBindTexture(GL_TEXTURE_2D,5);
  671.     glPushMatrix();
  672.     glTranslatef(5,0,105);
  673.     glScalef(0.1,40,20);
  674.     glTranslatef(-0.5,-0.5,-0.5);
  675.     cube(1,1,1);
  676.     glPopMatrix();
  677.     glDisable(GL_TEXTURE_2D);
  678.  
  679.     ///Inside Back Right
  680.     glEnable(GL_TEXTURE_2D);
  681.     glBindTexture(GL_TEXTURE_2D,5);
  682.     glPushMatrix();
  683.     glTranslatef(-5,0,105);
  684.     glScalef(0.1,40,20);
  685.     glTranslatef(-0.5,-0.5,-0.5);
  686.     cube(1,1,1);
  687.     glPopMatrix();
  688.     glDisable(GL_TEXTURE_2D);
  689.  
  690.     ///Inside Front Left2
  691.     glEnable(GL_TEXTURE_2D);
  692.     glBindTexture(GL_TEXTURE_2D,5);
  693.     glPushMatrix();
  694.     glTranslatef(-27.5,0,55);
  695.     glScalef(35,40,0.1);
  696.     glTranslatef(-0.5,-0.5,-0.5);
  697.     cube(1,1,1);
  698.     glPopMatrix();
  699.     glDisable(GL_TEXTURE_2D);
  700.     door(-7.5,7.5,55,1,5,25);
  701.  
  702.  
  703.     ///Inside Front Right2
  704.     glEnable(GL_TEXTURE_2D);
  705.     glBindTexture(GL_TEXTURE_2D,5);
  706.     glPushMatrix();
  707.     glTranslatef(27.5,0,55);
  708.     glScalef(35,40,0.1);
  709.     glTranslatef(-0.5,-0.5,-0.5);
  710.     cube(1,1,1);
  711.     glPopMatrix();
  712.     glDisable(GL_TEXTURE_2D);
  713.     door(7.5,7.5,55,2,5,25);
  714.  
  715.     ///Inside Back Left2
  716.     glEnable(GL_TEXTURE_2D);
  717.     glBindTexture(GL_TEXTURE_2D,5);
  718.     glPushMatrix();
  719.     glTranslatef(-27.5,0,95);
  720.     glScalef(35,40,0.1);
  721.     glTranslatef(-0.5,-0.5,-0.5);
  722.     cube(1,1,1);
  723.     glPopMatrix();
  724.     glDisable(GL_TEXTURE_2D);
  725.     door(-7.5,7.5,95,3,5,25);
  726.  
  727.     ///Inside Back Right2
  728.     glEnable(GL_TEXTURE_2D);
  729.     glBindTexture(GL_TEXTURE_2D,5);
  730.     glPushMatrix();
  731.     glTranslatef(27.5,0,95);
  732.     glScalef(35,40,0.1);
  733.     glTranslatef(-0.5,-0.5,-0.5);
  734.     cube(1,1,1);
  735.     glPopMatrix();
  736.     glDisable(GL_TEXTURE_2D);
  737.     door(7.5,7.5,95,4,5,25);
  738.  
  739.     ///Inside Right
  740.     glEnable(GL_TEXTURE_2D);
  741.     glBindTexture(GL_TEXTURE_2D,5);
  742.     glPushMatrix();
  743.     glTranslatef(-25,0,72.5);
  744.     glScalef(0.1,40,35);
  745.     glTranslatef(-0.5,-0.5,-0.5);
  746.     cube(1,1,1);
  747.     glPopMatrix();
  748.     glDisable(GL_TEXTURE_2D);
  749.  
  750.     glPushMatrix();
  751.     door(-27.5,7.5,90,5,5,25);
  752.     glPopMatrix();
  753.  
  754.     ///Inside Left
  755.     glEnable(GL_TEXTURE_2D);
  756.     glBindTexture(GL_TEXTURE_2D,5);
  757.     glPushMatrix();
  758.     glTranslatef(25,0,72.5);
  759.     glScalef(0.1,40,35);
  760.     glTranslatef(-0.5,-0.5,-0.5);
  761.     cube(1,1,1);
  762.     glPopMatrix();
  763.     glDisable(GL_TEXTURE_2D);
  764.  
  765.     glPushMatrix();
  766.     door(22.5,7.5,90,6,5,25);
  767.     glPopMatrix();
  768.  
  769. }
  770. void car()
  771. {
  772.  
  773.     glEnable(GL_LIGHTING);
  774.     //whole car
  775.     glPushMatrix();
  776.     //glRotatef(90,0,1,0);
  777.     glTranslatef(5,0.5,20);
  778.     //body
  779.  
  780.     glPushMatrix();
  781.     glTranslatef(0,1.5,0);
  782.     glScalef(8,2,3);
  783.     glTranslatef(-0.5,-0.5,-0.5);
  784.     //cube();
  785.     cube(0.9,0.9,0.9);
  786.     //cube(0.5804,0.5451,0.5568);
  787.     glPopMatrix();
  788.  
  789.  
  790.     //top
  791.     glPushMatrix();
  792.     glTranslatef(0,3.5,0);
  793.     glScalef(4,2,3);
  794.     glTranslatef(-0.5,-0.5,-0.5);
  795.     //cube();
  796.     cube(0.7569,0.7569,0.847);
  797.     //cube(0.5804,0.5451,0.5568);
  798.     glPopMatrix();
  799.  
  800.     //glass
  801.     glPushMatrix();
  802.     glTranslatef(0.95,3.45,1.5);
  803.     glScalef(1.8,1.8,0.1);
  804.     glTranslatef(-0.5,-0.5,-0.5);
  805.     //cube();
  806.     cube(0,0,0);
  807.     //cube(0.5804,0.5451,0.5568);
  808.     glPopMatrix();
  809.  
  810.     glPushMatrix();
  811.     glTranslatef(-0.95,3.45,1.5);
  812.     glScalef(1.8,1.8,0.1);
  813.     glTranslatef(-0.5,-0.5,-0.5);
  814.     //cube();
  815.     cube(0,0,0);
  816.     //cube(0.5804,0.5451,0.5568);
  817.     glPopMatrix();
  818.  
  819.     glPushMatrix();
  820.     glTranslatef(0.95,3.45,-1.5);
  821.     glScalef(1.8,1.8,0.1);
  822.     glTranslatef(-0.5,-0.5,-0.5);
  823.     //cube();
  824.     cube(0,0,0);
  825.     //cube(0.5804,0.5451,0.5568);
  826.     glPopMatrix();
  827.  
  828.     glPushMatrix();
  829.     glTranslatef(-0.95,3.45,-1.5);
  830.     glScalef(1.8,1.8,0.1);
  831.     glTranslatef(-0.5,-0.5,-0.5);
  832.     //cube();
  833.     cube(0,0,0);
  834.     //cube(0.5804,0.5451,0.5568);
  835.     glPopMatrix();
  836.  
  837.     //front glass
  838.  
  839.     glPushMatrix();
  840.     glTranslatef(2,3.45,0);
  841.     glScalef(0.1,1.8,3);
  842.     glTranslatef(-0.5,-0.5,-0.5);
  843.     //cube();
  844.     cube(0,0,0);
  845.     //cube(0.5804,0.5451,0.5568);
  846.     glPopMatrix();
  847.  
  848.     glPushMatrix();
  849.     glTranslatef(-2,3.45,0);
  850.     glScalef(0.1,1.8,3);
  851.     glTranslatef(-0.5,-0.5,-0.5);
  852.     //cube();
  853.     cube(0,0,0);
  854.     //cube(0.5804,0.5451,0.5568);
  855.     glPopMatrix();
  856.  
  857.  
  858.     //frontlight
  859.     glEnable(GL_TEXTURE_2D);
  860.     glBindTexture(GL_TEXTURE_2D,8);
  861.     glPushMatrix();
  862.     glTranslatef(-4,1.45,0);
  863.     glScalef(0.1,1.8,3);
  864.     glTranslatef(-0.5,-0.5,-0.5);
  865.     //cube();
  866.     cube();
  867.     //cube(0.5804,0.5451,0.5568);
  868.     glPopMatrix();
  869.     glDisable(GL_TEXTURE_2D);
  870.  
  871.     //backlight
  872.     glEnable(GL_TEXTURE_2D);
  873.     glBindTexture(GL_TEXTURE_2D,8);
  874.     glPushMatrix();
  875.     glTranslatef(4,1.45,0);
  876.     glScalef(0.1,1.8,3);
  877.     glTranslatef(-0.5,-0.5,-0.5);
  878.     //cube();
  879.     set_material(0.5,0.5,0.5,true,press4);
  880.     cube();
  881.     //cube(0.5804,0.5451,0.5568);
  882.     glPopMatrix();
  883.     glDisable(GL_TEXTURE_2D);
  884.     glPopMatrix();
  885.  
  886.     glDisable(GL_LIGHTING);
  887.  
  888. }
  889.  
  890. void LoadTexture(const char*filename)
  891. {
  892.     glGenTextures(1, &ID);
  893.     glBindTexture(GL_TEXTURE_2D, ID);
  894.     glPixelStorei(GL_UNPACK_ALIGNMENT, ID);
  895.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
  896.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
  897.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
  898.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  899.     BmpLoader bl(filename);
  900.     gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, bl.iWidth, bl.iHeight, GL_RGB, GL_UNSIGNED_BYTE, bl.textureData );
  901. }
  902.  
  903. void cover()
  904. {
  905.  
  906.     ///Front
  907.     glEnable(GL_TEXTURE_2D);
  908.     glBindTexture(GL_TEXTURE_2D,9);
  909.     glPushMatrix();
  910.     glTranslatef(0,20,45);
  911.     glScalef(90,0.1,20);
  912.     glTranslatef(-0.5,-0.5,-0.5);
  913.     cube(1,1,1);
  914.     glPopMatrix();
  915.     glDisable(GL_TEXTURE_2D);
  916.  
  917.     ///Back
  918.     glEnable(GL_TEXTURE_2D);
  919.     glBindTexture(GL_TEXTURE_2D,9);
  920.     glPushMatrix();
  921.     glTranslatef(0,20,105);
  922.     glScalef(90,0.1,20);
  923.     glTranslatef(-0.5,-0.5,-0.5);
  924.     cube(1,1,1);
  925.     glPopMatrix();
  926.     glDisable(GL_TEXTURE_2D);
  927.  
  928.     ///Left
  929.     glEnable(GL_TEXTURE_2D);
  930.     glBindTexture(GL_TEXTURE_2D,9);
  931.     glPushMatrix();
  932.     glTranslatef(35,20,75);
  933.     glScalef(20,0.1,40);
  934.     glTranslatef(-0.5,-0.5,-0.5);
  935.     cube(1,1,1);
  936.     glPopMatrix();
  937.     glDisable(GL_TEXTURE_2D);
  938.  
  939.     ///Right
  940.     glEnable(GL_TEXTURE_2D);
  941.     glBindTexture(GL_TEXTURE_2D,9);
  942.     glPushMatrix();
  943.     glTranslatef(-35,20,75);
  944.     glScalef(20,0.1,40);
  945.     glTranslatef(-0.5,-0.5,-0.5);
  946.     cube(1,1,1);
  947.     glPopMatrix();
  948.     glDisable(GL_TEXTURE_2D);
  949. }
  950. void goalpost()
  951. {
  952.     ///Left Post
  953.     glEnable(GL_TEXTURE_2D);
  954.     glBindTexture(GL_TEXTURE_2D,10);
  955.     glPushMatrix();
  956.     glTranslatef(17.5,0,78);
  957.     glScalef(0.3,15,0.3);
  958.     glTranslatef(-0.5,-0.5,-0.5);
  959.     cube(1,1,1);
  960.     glPopMatrix();
  961.     glDisable(GL_TEXTURE_2D);
  962.  
  963.     glEnable(GL_TEXTURE_2D);
  964.     glBindTexture(GL_TEXTURE_2D,10);
  965.     glPushMatrix();
  966.     glTranslatef(17.5,0,72);
  967.     glScalef(0.3,15,0.3);
  968.     glTranslatef(-0.5,-0.5,-0.5);
  969.     cube(1,1,1);
  970.     glPopMatrix();
  971.     glDisable(GL_TEXTURE_2D);
  972.  
  973.     glEnable(GL_TEXTURE_2D);
  974.     glBindTexture(GL_TEXTURE_2D,10);
  975.     glPushMatrix();
  976.     glTranslatef(17.5,7.5,75);
  977.     glRotatef(90,1,0,0);
  978.     glScalef(0.3,6,0.3);
  979.     glTranslatef(-0.5,-0.5,-0.5);
  980.     cube(1,1,1);
  981.     glPopMatrix();
  982.     glDisable(GL_TEXTURE_2D);
  983.  
  984.  
  985.     ///Right Post
  986.     glEnable(GL_TEXTURE_2D);
  987.     glBindTexture(GL_TEXTURE_2D,10);
  988.     glPushMatrix();
  989.     glTranslatef(-17.5,0,78);
  990.     glScalef(0.3,15,0.3);
  991.     glTranslatef(-0.5,-0.5,-0.5);
  992.     cube(1,1,1);
  993.     glPopMatrix();
  994.     glDisable(GL_TEXTURE_2D);
  995.  
  996.     glEnable(GL_TEXTURE_2D);
  997.     glBindTexture(GL_TEXTURE_2D,10);
  998.     glPushMatrix();
  999.     glTranslatef(-17.5,0,72);
  1000.     glScalef(0.3,15,0.3);
  1001.     glTranslatef(-0.5,-0.5,-0.5);
  1002.     cube(1,1,1);
  1003.     glPopMatrix();
  1004.     glDisable(GL_TEXTURE_2D);
  1005.  
  1006.     glEnable(GL_TEXTURE_2D);
  1007.     glBindTexture(GL_TEXTURE_2D,10);
  1008.     glPushMatrix();
  1009.     glTranslatef(-17.5,7.5,75);
  1010.     glRotatef(90,1,0,0);
  1011.     glScalef(0.3,6,0.3);
  1012.     glTranslatef(-0.5,-0.5,-0.5);
  1013.     cube(1,1,1);
  1014.     glPopMatrix();
  1015.     glDisable(GL_TEXTURE_2D);
  1016. }
  1017. void fence()
  1018. {
  1019.     ///Fence Left
  1020.     glEnable(GL_TEXTURE_2D);
  1021.     glBindTexture(GL_TEXTURE_2D,3);
  1022.     glPushMatrix();
  1023.     glTranslatef(30,0,25);
  1024.     glScalef(50,10,0.5);
  1025.     glTranslatef(-0.5,-0.5,-0.5);
  1026.     cube(1,1,1);
  1027.     glPopMatrix();
  1028.     glDisable(GL_TEXTURE_2D);
  1029.  
  1030.     glEnable(GL_TEXTURE_2D);
  1031.     glBindTexture(GL_TEXTURE_2D,3);
  1032.     glPushMatrix();
  1033.     glTranslatef(55,0,75);
  1034.     glScalef(0.5,10,100);
  1035.     glTranslatef(-0.5,-0.5,-0.5);
  1036.     cube(1,1,1);
  1037.     glPopMatrix();
  1038.     glDisable(GL_TEXTURE_2D);
  1039.  
  1040.     ///Fence Right
  1041.     glEnable(GL_TEXTURE_2D);
  1042.     glBindTexture(GL_TEXTURE_2D,3);
  1043.     glPushMatrix();
  1044.     glTranslatef(-30,0,25);
  1045.     glScalef(50,10,0.5);
  1046.     glTranslatef(-0.5,-0.5,-0.5);
  1047.     cube(1,1,1);
  1048.     glPopMatrix();
  1049.     glDisable(GL_TEXTURE_2D);
  1050.  
  1051.     glEnable(GL_TEXTURE_2D);
  1052.     glBindTexture(GL_TEXTURE_2D,3);
  1053.     glPushMatrix();
  1054.     glTranslatef(-55,0,75);
  1055.     glScalef(0.5,10,100);
  1056.     glTranslatef(-0.5,-0.5,-0.5);
  1057.     cube(1,1,1);
  1058.     glPopMatrix();
  1059.     glDisable(GL_TEXTURE_2D);
  1060. }
  1061. void wardrobe(float x,float y,float z)
  1062. {
  1063.  
  1064.     ///wardrobe body
  1065.     glEnable(GL_TEXTURE_2D);
  1066.     glBindTexture(GL_TEXTURE_2D,11);
  1067.     glPushMatrix();
  1068.     glTranslatef(x,y,z);
  1069.     glScalef(10,20,5);
  1070.     glTranslatef(-0.5,-0.5,-0.5);
  1071.     cube(1,1,1);
  1072.     glPopMatrix();
  1073.     glDisable(GL_TEXTURE_2D);
  1074.  
  1075.     ///wardrobe front
  1076.     glEnable(GL_TEXTURE_2D);
  1077.     glBindTexture(GL_TEXTURE_2D,12);
  1078.     glPushMatrix();
  1079.     glTranslatef(x+5,y,z);
  1080.     glScalef(0.1,20,5);
  1081.     glTranslatef(-0.5,-0.5,-0.5);
  1082.     cube(1,1,1);
  1083.     glPopMatrix();
  1084.     glDisable(GL_TEXTURE_2D);
  1085. }
  1086. void board()
  1087. {
  1088.  
  1089.     glPushMatrix();
  1090. //    glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
  1091. //    glEnable ( GL_COLOR_MATERIAL ) ;
  1092. //    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,0);
  1093.     glEnable(GL_LIGHTING);
  1094.     glTranslatef(5.1,15,48);
  1095.     glScalef(0.1,5,10);
  1096.     glTranslatef(-0.5,-0.5,-0.5);
  1097.     cube(0,0,0,1,1);
  1098.     glDisable(GL_LIGHTING);
  1099.     glPopMatrix();
  1100.  
  1101. }
  1102. void clock()
  1103. {
  1104.     glEnable(GL_TEXTURE_2D);
  1105.     glBindTexture(GL_TEXTURE_2D,14);
  1106.     glPushMatrix();
  1107.     glTranslatef(15,4,44);
  1108.     ///Clock
  1109.     glPushMatrix();
  1110.     glTranslatef(5.3,10.5,9.6);
  1111.     glScalef(4,4,0.1);
  1112.     cube(1,1,1);
  1113.     glPopMatrix();
  1114.  
  1115.     ///Circle
  1116.     glPushMatrix();
  1117.     glTranslatef(0,5,10);
  1118.     glScalef(15,15,15);
  1119.     DrawCircle(0.5, 0.5, 0.2, 100);
  1120.     glPopMatrix();
  1121.     glPopMatrix();
  1122.     glDisable(GL_TEXTURE_2D);
  1123. }
  1124. void fan()
  1125. {
  1126.     float height = 10;
  1127.  
  1128.     glPushMatrix();
  1129.     glEnable(GL_LIGHTING);
  1130.     glTranslatef(25,10,45);
  1131.     //glScalef(10,5,10);
  1132. //    for(int i=0; i<=360 ; i=i+10)
  1133. //    {
  1134. //
  1135. //        glPushMatrix();
  1136. //        glTranslatef(0,height,0);
  1137. //        glRotatef(i,0,1,0);
  1138. //        glScalef(5,2.5/8,2.5);
  1139. //        glTranslatef(-0.5,0,-0.5);
  1140. //        cube(0.502, 0.000, 0.502);
  1141. //        glPopMatrix();
  1142. //
  1143. //    }
  1144.  
  1145.     glPushMatrix();
  1146.     glTranslatef(0,height-5-2.5/8,0);
  1147.     glScalef(1,4,1);
  1148.     glTranslatef(-0.5,0,-0.5);
  1149.     cube(0,0,0);
  1150.     glPopMatrix();
  1151.  
  1152.     glPushMatrix();
  1153.     glRotatef(spin,0,1,0);
  1154.     for(int i=0; i<=360 ; i=i+10)
  1155.     {
  1156.  
  1157.         glPushMatrix();
  1158.         glTranslatef(0,height-5-2.5/8-2.5,0);
  1159.         glRotatef(i,0,1,0);
  1160.         glScalef(5,2.5,2.5);
  1161.         glTranslatef(-0.5,0,-0.5);
  1162.         cube(1.000, 1.000, 0.000);
  1163.         glPopMatrix();
  1164.  
  1165.     }
  1166.  
  1167.     glPushMatrix();
  1168.     glTranslatef(0,height-5-2.5/8-2.5+1,0);
  1169.     glScalef(15,0.5,2.5);
  1170.     glTranslatef(-0.5,0,-0.5);
  1171.     cube(0, 0.000, 0.502);
  1172.     glPopMatrix();
  1173.  
  1174.     glPushMatrix();
  1175.     glTranslatef(0,height-5-2.5/8-2.5+1,0);
  1176.     glScalef(2.5,0.5,15);
  1177.     glTranslatef(-0.5,0,-0.5);
  1178.     cube(0, 0.000, 0.502);
  1179.  
  1180.     glPopMatrix();
  1181.  
  1182.     glPopMatrix();
  1183.     glDisable(GL_LIGHTING);
  1184.     glPopMatrix();
  1185. }
  1186.  
  1187. void table(float x,float y,float z, unsigned int id=11)
  1188. {
  1189.     float height=6;
  1190.     float width=5;
  1191.     float length=5;
  1192.  
  1193.     float base_height=1;
  1194.     float leg_height=height-base_height;
  1195.     float leg_width=0.5;
  1196.  
  1197.     // whole table
  1198.     glEnable(GL_TEXTURE_2D);
  1199.     glBindTexture(GL_TEXTURE_2D,id);
  1200.     glPushMatrix();
  1201.     glTranslatef(x,y,z);
  1202.  
  1203.     // base
  1204.     glPushMatrix();
  1205.     glScalef(width,base_height,length);
  1206.     glTranslatef(-0.5,0,-0.5);
  1207.     cube(0.53,0.39,0.28);
  1208.     glPopMatrix();
  1209.  
  1210.     // legs
  1211.     glPushMatrix();
  1212.     glTranslatef((width/2-leg_width/2),0,(length/2-leg_width/2));
  1213.     glScalef(leg_width,leg_height,leg_width);
  1214.     glTranslatef(-0.5,-1,-0.5);
  1215.     cube(0.53,0.39,0.28);
  1216.     glPopMatrix();
  1217.  
  1218.     glPushMatrix();
  1219.     glTranslatef((width/2-leg_width/2),0,-(length/2-leg_width/2));
  1220.     glScalef(leg_width,leg_height,leg_width);
  1221.     glTranslatef(-0.5,-1,-0.5);
  1222.     cube(0.53,0.39,0.28);
  1223.     glPopMatrix();
  1224.  
  1225.     glPushMatrix();
  1226.     glTranslatef(-(width/2-leg_width/2),0,(length/2-leg_width/2));
  1227.     glScalef(leg_width,leg_height,leg_width);
  1228.     glTranslatef(-0.5,-1,-0.5);
  1229.     cube(0.53,0.39,0.28);
  1230.     glPopMatrix();
  1231.  
  1232.     glPushMatrix();
  1233.     glTranslatef(-(width/2-leg_width/2),0,-(length/2-leg_width/2));
  1234.     glScalef(leg_width,leg_height,leg_width);
  1235.     glTranslatef(-0.5,-1,-0.5);
  1236.     cube(0.53,0.39,0.28);
  1237.     glPopMatrix();
  1238.  
  1239.     glPopMatrix();
  1240.     glDisable(GL_TEXTURE_2D);
  1241.  
  1242. }
  1243.  
  1244.  
  1245. void chair(float x,float y,float z,int turned=0)
  1246. {
  1247.     float height=3;
  1248.     float width=3;
  1249.     float length=3;
  1250.  
  1251.     float base_height=1;
  1252.     float leg_height=height-base_height;
  1253.     float leg_width=0.5;
  1254.  
  1255.     // whole chair
  1256.     glEnable(GL_TEXTURE_2D);
  1257.     glBindTexture(GL_TEXTURE_2D,13);
  1258.     glPushMatrix();
  1259.     glTranslatef(x,y,z);
  1260.     if(!turned)
  1261.         glRotatef(180,0,1,0);
  1262.     else if(turned==3)
  1263.         glRotatef(90,0,1,0);
  1264.     else if(turned==2)
  1265.         glRotatef(270,0,1,0);
  1266.  
  1267.     // base
  1268.     glPushMatrix();
  1269.     glScalef(width,base_height-0.5,length);
  1270.     glTranslatef(-0.5,0,-0.5);
  1271.     cube(0.53,0.39,0.28);
  1272.     glPopMatrix();
  1273.  
  1274.     //back
  1275.     glPushMatrix();
  1276.     glTranslatef(-(width/2-leg_width/2),0,0);
  1277.     glScalef(0.5,height,length);
  1278.     glTranslatef(-0.5,0,-0.5);
  1279.     cube(0.53,0.39,0.28);
  1280.     glPopMatrix();
  1281.  
  1282.     // legs
  1283.     glPushMatrix();
  1284.     glTranslatef((width/2-leg_width/2),0,(length/2-leg_width/2));
  1285.     glScalef(leg_width,leg_height,leg_width);
  1286.     glTranslatef(-0.5,-1,-0.5);
  1287.     cube(0.53,0.39,0.28);
  1288.     glPopMatrix();
  1289.  
  1290.     glPushMatrix();
  1291.     glTranslatef((width/2-leg_width/2),0,-(length/2-leg_width/2));
  1292.     glScalef(leg_width,leg_height,leg_width);
  1293.     glTranslatef(-0.5,-1,-0.5);
  1294.     cube(0.53,0.39,0.28);
  1295.     glPopMatrix();
  1296.  
  1297.     glPushMatrix();
  1298.     glTranslatef(-(width/2-leg_width/2),0,(length/2-leg_width/2));
  1299.     glScalef(leg_width,leg_height,leg_width);
  1300.     glTranslatef(-0.5,-1,-0.5);
  1301.     cube(0.53,0.39,0.28);
  1302.     glPopMatrix();
  1303.  
  1304.     glPushMatrix();
  1305.     glTranslatef(-(width/2-leg_width/2),0,-(length/2-leg_width/2));
  1306.     glScalef(leg_width,leg_height,leg_width);
  1307.     glTranslatef(-0.5,-1,-0.5);
  1308.     cube(0.53,0.39,0.28);
  1309.     glPopMatrix();
  1310.  
  1311.     glPopMatrix();
  1312.     glDisable(GL_TEXTURE_2D);
  1313.  
  1314. }
  1315.  
  1316. void tv()
  1317. {
  1318.  
  1319.     glEnable(GL_TEXTURE_2D);
  1320.     glBindTexture(GL_TEXTURE_2D,10);
  1321.     glPushMatrix();
  1322.     glTranslatef(-26,13,70);
  1323.     glScalef(1,5,5);
  1324.     cube(1,1,1);
  1325.     glPopMatrix();
  1326.     glDisable(GL_TEXTURE_2D);
  1327.  
  1328.     glEnable(GL_LIGHTING);
  1329.     glPushMatrix();
  1330.     glTranslatef(-26,13,69);
  1331.     glScalef(1,5,1);
  1332.     cube(0,0,0);
  1333.     glPopMatrix();
  1334.  
  1335.     glPushMatrix();
  1336.     glTranslatef(-26,13,75);
  1337.     glScalef(1,5,1);
  1338.     cube(0,0,0);
  1339.     glPopMatrix();
  1340.  
  1341.     glPushMatrix();
  1342.     glTranslatef(-26,12,70);
  1343.     glScalef(1,1,6);
  1344.     cube(0,0,0);
  1345.     glPopMatrix();
  1346.     glPushMatrix();
  1347.     glTranslatef(-26,18,70);
  1348.     glScalef(1,1,6);
  1349.     cube(0,0,0);
  1350.     glPopMatrix();
  1351.     glDisable(GL_LIGHTING);
  1352. }
  1353. void carrom()
  1354. {
  1355.     glEnable(GL_TEXTURE_2D);
  1356.     glBindTexture(GL_TEXTURE_2D,15);
  1357.     glPushMatrix();
  1358.     glTranslatef(30,7,65);
  1359.     glScalef(5,1,5);
  1360.     glTranslatef(-0.5,-0.5,-0.5);
  1361.     cube(1,1,1);
  1362.     glPopMatrix();
  1363.     glDisable(GL_TEXTURE_2D);
  1364.  
  1365.  
  1366.     glPushMatrix();
  1367.     glTranslatef(1,0,0);
  1368.     glEnable(GL_LIGHTING);
  1369.     glPushMatrix();
  1370.     glTranslatef(31.5,7.1,65);
  1371.     glScalef(0.5,1,5);
  1372.     glTranslatef(-0.5,-0.5,-0.5);
  1373.     cube(0,0,0);
  1374.     glPopMatrix();
  1375.     glDisable(GL_LIGHTING);
  1376.  
  1377.     glEnable(GL_LIGHTING);
  1378.     glPushMatrix();
  1379.     glTranslatef(26.5,7.1,65);
  1380.     glScalef(0.5,1,5);
  1381.     glTranslatef(-0.5,-0.5,-0.5);
  1382.     cube(0,0,0);
  1383.     glPopMatrix();
  1384.     glDisable(GL_LIGHTING);
  1385.  
  1386.     glEnable(GL_LIGHTING);
  1387.     glPushMatrix();
  1388.     glTranslatef(29,7.1,67.5);
  1389.     glRotatef(90,0,1,0);
  1390.     glScalef(0.5,1,5);
  1391.     glTranslatef(-0.5,-0.5,-0.5);
  1392.     cube(0,0,0);
  1393.     glPopMatrix();
  1394.     glDisable(GL_LIGHTING);
  1395.  
  1396.     glEnable(GL_LIGHTING);
  1397.     glPushMatrix();
  1398.     glTranslatef(29,7.1,62.5);
  1399.     glRotatef(90,0,1,0);
  1400.     glScalef(0.5,1,5);
  1401.     glTranslatef(-0.5,-0.5,-0.5);
  1402.     cube(0,0,0);
  1403.     glPopMatrix();
  1404.     glDisable(GL_LIGHTING);
  1405.  
  1406.     glPopMatrix();
  1407.     ///Carrom balls
  1408.     glEnable(GL_LIGHTING);
  1409.     glPushMatrix();
  1410.     glTranslatef(30,7.2,64);
  1411.     glRotatef(90,1,1,0);
  1412.     glScalef(1,1,1);
  1413.     DrawCircle(0.5, 0.5, 0.2, 100);
  1414.     glPopMatrix();
  1415.     glDisable(GL_LIGHTING);
  1416.  
  1417.     glEnable(GL_LIGHTING);
  1418.     glPushMatrix();
  1419.     glTranslatef(29,7.2,64.5);
  1420.     glRotatef(90,1,1,0);
  1421.     glScalef(1,1,1);
  1422.     DrawCircle(0.5, 0.5, 0.2, 100);
  1423.     glPopMatrix();
  1424.     glDisable(GL_LIGHTING);
  1425.  
  1426.     glEnable(GL_LIGHTING);
  1427.     glPushMatrix();
  1428.     glTranslatef(28,7.2,65);
  1429.     glRotatef(90,1,1,0);
  1430.     glScalef(1,1,1);
  1431.     DrawCircle(0.5, 0.5, 0.2, 100);
  1432.     glPopMatrix();
  1433.     glDisable(GL_LIGHTING);
  1434.  
  1435.     glEnable(GL_LIGHTING);
  1436.     glPushMatrix();
  1437.     glTranslatef(27.5,7.2,65.5);
  1438.     glRotatef(90,1,1,0);
  1439.     glScalef(1,1,1);
  1440.     DrawCircle(0.5, 0.5, 0.2, 100);
  1441.     glPopMatrix();
  1442.     glDisable(GL_LIGHTING);
  1443.  
  1444.  
  1445.     glPushMatrix();
  1446.     glTranslatef(30,7.2,66);
  1447.     glRotatef(90,1,1,0);
  1448.     glScalef(1,1,1);
  1449.     DrawCircle(0.5, 0.5, 0.2, 100);
  1450.     glPopMatrix();
  1451.  
  1452.     glPushMatrix();
  1453.     glTranslatef(29,7.2,66.5);
  1454.     glRotatef(90,1,1,0);
  1455.     glScalef(1,1,1);
  1456.     DrawCircle(0.5, 0.5, 0.2, 100);
  1457.     glPopMatrix();
  1458.  
  1459.     glPushMatrix();
  1460.     glTranslatef(28,7.2,63);
  1461.     glRotatef(90,1,1,0);
  1462.     glScalef(1,1,1);
  1463.     DrawCircle(0.5, 0.5, 0.2, 100);
  1464.     glPopMatrix();
  1465.  
  1466.  
  1467.  
  1468.     glPushMatrix();
  1469.     glTranslatef(28,7.2,63.5);
  1470.     glRotatef(90,1,1,0);
  1471.     glScalef(1,1,1);
  1472.     DrawCircle(0.5, 0.5, 0.2, 100);
  1473.     glPopMatrix();
  1474.  
  1475.  
  1476.     table(30,6,65);
  1477. }
  1478.  
  1479. void pingpong()
  1480. {
  1481.     glEnable(GL_TEXTURE_2D);
  1482.     glBindTexture(GL_TEXTURE_2D,13);
  1483.     glPushMatrix();
  1484.     glTranslatef(38,7,65);
  1485.     glScalef(5,1,5);
  1486.     glTranslatef(-0.5,-0.5,-0.5);
  1487.     cube(1,1,1);
  1488.     glPopMatrix();
  1489.     glDisable(GL_TEXTURE_2D);
  1490.  
  1491.  
  1492.  
  1493.     glPushMatrix();
  1494.     glTranslatef(40.5,8,65);
  1495.     glScalef(0.3,1.5,0.3);
  1496.     glTranslatef(-0.5,-0.5,-0.5);
  1497.     cube(1,1,1);
  1498.     glPopMatrix();
  1499.  
  1500.  
  1501.  
  1502.     glPushMatrix();
  1503.     glTranslatef(35.5,8,65);
  1504.     glScalef(0.3,1.5,0.3);
  1505.     glTranslatef(-0.5,-0.5,-0.5);
  1506.     cube(1,1,1);
  1507.     glPopMatrix();
  1508.  
  1509.     glEnable(GL_TEXTURE_2D);
  1510.     glBindTexture(GL_TEXTURE_2D,18);
  1511.     glPushMatrix();
  1512.     glTranslatef(38,8,65);
  1513.     glScalef(4.5,1.5,0.1);
  1514.     glTranslatef(-0.5,-0.5,-0.5);
  1515.     cube(1,1,1);
  1516.     glPopMatrix();
  1517.     glDisable(GL_TEXTURE_2D);
  1518.  
  1519.     table(38,6,65);
  1520. }
  1521.  
  1522.  
  1523. void dart()
  1524. {
  1525.     glEnable(GL_TEXTURE_2D);
  1526.     glBindTexture(GL_TEXTURE_2D,17);
  1527.     glPushMatrix();
  1528.     glTranslatef(35,15,94);
  1529.     glScalef(6,6,0.1);
  1530.     glTranslatef(-0.5,-0.5,-0.5);
  1531.     cube(1,1,1);
  1532.     glPopMatrix();
  1533.     glDisable(GL_TEXTURE_2D);
  1534.  
  1535. }
  1536. void chess()
  1537. {
  1538.     table(38,6,75);
  1539.  
  1540.     glEnable(GL_TEXTURE_2D);
  1541.     glBindTexture(GL_TEXTURE_2D,16);
  1542.     glPushMatrix();
  1543.     glTranslatef(38,7,75);
  1544.     glScalef(4,1,4);
  1545.     glTranslatef(-0.5,-0.5,-0.5);
  1546.     cube(1,1,1);
  1547.     glPopMatrix();
  1548.     glDisable(GL_TEXTURE_2D);
  1549.  
  1550.     glPushMatrix();
  1551.     //glRotatef(90,0,1,0);
  1552.     chair(36,6,75,1);
  1553.     chair(40,6,75);
  1554.     glPopMatrix();
  1555. }
  1556.  
  1557.  
  1558.  
  1559. void classroom1(int id)
  1560. {
  1561.  
  1562.     if(id==2)
  1563.     {
  1564.         wardrobe(11,7.5,48);
  1565.         //chairtable();
  1566.         table(12,6,39);
  1567.         chair(10,6,39,1);
  1568.     }
  1569.     else
  1570.     {
  1571.         wardrobe(11,7.5,39);
  1572.         //chairtable();
  1573.         table(12,6,48);
  1574.         chair(10,6,48,1);
  1575.     }
  1576.  
  1577.     board();
  1578.     clock();
  1579.     fan();
  1580.  
  1581.  
  1582.  
  1583.     table(20,6,38);
  1584.     chair(22,6,38);
  1585.     table(20,6,45);
  1586.     chair(22,6,45);
  1587.     table(20,6,52);
  1588.     chair(22,6,52);
  1589.  
  1590.     table(30,6,38);
  1591.     chair(32,6,38);
  1592.     table(30,6,45);
  1593.     chair(32,6,45);
  1594.     table(30,6,52);
  1595.     chair(32,6,52);
  1596.  
  1597.     table(40,6,38);
  1598.     chair(42,6,38);
  1599.     table(40,6,45);
  1600.     chair(42,6,45);
  1601.     table(40,6,52);
  1602.     chair(42,6,52);
  1603.  
  1604. }
  1605.  
  1606. void lab()
  1607. {
  1608.  
  1609. }
  1610. void sports()
  1611. {
  1612.     carrom();
  1613.     pingpong();
  1614.     chess();
  1615.     dart();
  1616.  
  1617. }
  1618.  
  1619. void trees()
  1620. {
  1621.  
  1622.  
  1623.     glEnable(GL_TEXTURE_2D);
  1624.     glBindTexture(GL_TEXTURE_2D,2);
  1625.     glPushMatrix();
  1626.     glTranslatef(10,5,10);
  1627.     glScalef(2,2,2);
  1628.     drawpyramid();
  1629.     glPopMatrix();
  1630.     glDisable(GL_TEXTURE_2D);
  1631.  
  1632.     glEnable(GL_TEXTURE_2D);
  1633.     glBindTexture(GL_TEXTURE_2D,2);
  1634.     glPushMatrix();
  1635.     glTranslatef(10,5,20);
  1636.     glScalef(2,2,2);
  1637.     drawpyramid();
  1638.     glPopMatrix();
  1639.     glDisable(GL_TEXTURE_2D);
  1640.  
  1641.  
  1642.     glEnable(GL_TEXTURE_2D);
  1643.     glBindTexture(GL_TEXTURE_2D,2);
  1644.     glPushMatrix();
  1645.     glTranslatef(10,5,0);
  1646.     glScalef(2,2,2);
  1647.     drawpyramid();
  1648.     glPopMatrix();
  1649.     glDisable(GL_TEXTURE_2D);
  1650.  
  1651.     glEnable(GL_TEXTURE_2D);
  1652.     glBindTexture(GL_TEXTURE_2D,2);
  1653.     glPushMatrix();
  1654.     glTranslatef(-12,5,10);
  1655.     glScalef(2,2,2);
  1656.     drawpyramid();
  1657.     glPopMatrix();
  1658.     glDisable(GL_TEXTURE_2D);
  1659.  
  1660.     glEnable(GL_TEXTURE_2D);
  1661.     glBindTexture(GL_TEXTURE_2D,2);
  1662.     glPushMatrix();
  1663.     glTranslatef(-12,5,20);
  1664.     glScalef(2,2,2);
  1665.     drawpyramid();
  1666.     glPopMatrix();
  1667.     glDisable(GL_TEXTURE_2D);
  1668.  
  1669.  
  1670.     glEnable(GL_TEXTURE_2D);
  1671.     glBindTexture(GL_TEXTURE_2D,2);
  1672.     glPushMatrix();
  1673.     glTranslatef(-12,5,0);
  1674.     glScalef(2,2,2);
  1675.     drawpyramid();
  1676.     glPopMatrix();
  1677.     glDisable(GL_TEXTURE_2D);
  1678.  
  1679.  
  1680.     glEnable(GL_LIGHTING);
  1681.  
  1682.     glPushMatrix();
  1683.     glTranslatef(10,0,20);
  1684.     glScalef(1,5,1);
  1685.     cube(0,0,0);
  1686.     glPopMatrix();
  1687.  
  1688.     glPushMatrix();
  1689.     glTranslatef(10,0,10);
  1690.     glScalef(1,5,1);
  1691.     cube(0,0,0);
  1692.     glPopMatrix();
  1693.  
  1694.     glPushMatrix();
  1695.     glTranslatef(10,0,0);
  1696.     glScalef(1,5,1);
  1697.     cube(0,0,0);
  1698.     glPopMatrix();
  1699.  
  1700.     glPushMatrix();
  1701.     glTranslatef(-10,0,20);
  1702.     glScalef(1,5,1);
  1703.     cube(0,0,0);
  1704.     glPopMatrix();
  1705.  
  1706.     glPushMatrix();
  1707.     glTranslatef(-10,0,10);
  1708.     glScalef(1,5,1);
  1709.     cube(0,0,0);
  1710.     glPopMatrix();
  1711.  
  1712.     glPushMatrix();
  1713.     glTranslatef(-10,0,0);
  1714.     glScalef(1,5,1);
  1715.     cube(0,0,0);
  1716.     glPopMatrix();
  1717.  
  1718.     glDisable(GL_LIGHTING);
  1719. }
  1720.  
  1721. void teachers()
  1722. {
  1723.     glEnable(GL_TEXTURE_2D);
  1724.     glBindTexture(GL_TEXTURE_2D,3);
  1725.     glPushMatrix();
  1726.     glTranslatef(-40,6,66);
  1727.     glScalef(10,1,26);
  1728.     cube(1,1,1);
  1729.     glPopMatrix();
  1730.     glDisable(GL_TEXTURE_2D);
  1731.     glPushMatrix();
  1732.     glScalef(2,1,5);
  1733.     table(-17.5,5,15.8);
  1734.     glPopMatrix();
  1735.  
  1736.     chair(-28,5,70);
  1737.     chair(-28,5,75);
  1738.     chair(-28,5,80);
  1739.     chair(-28,5,85);
  1740.     chair(-28,5,90);
  1741.     chair(-43,5,70,1);
  1742.     chair(-43,5,75,1);
  1743.     chair(-43,5,80,1);
  1744.     chair(-43,5,85,1);
  1745.     chair(-43,5,90,1);
  1746.  
  1747.  
  1748.     //glRotatef(90,0,1,0);
  1749.     chair(-35,5,65,2);
  1750.     chair(-35,5,92,3);
  1751.     wardrobe(-35,7.5,60);
  1752.     tv();
  1753.  
  1754. }
  1755. static void display(void)
  1756. {
  1757.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  1758.     glMatrixMode(GL_PROJECTION);
  1759.     glLoadIdentity();
  1760.     glFrustum(-3, 3, -3, 3, 2.0, 100.0);
  1761.  
  1762.     glMatrixMode(GL_MODELVIEW);
  1763.     glLoadIdentity();
  1764.     gluLookAt(eyeX,eyeY,eyeZ, lookX,lookY,lookZ, 0,1,0);
  1765.     //glViewport(0, 0, width, height);
  1766.  
  1767.     glRotatef(rot, 0,1,0);
  1768.     //axes();
  1769.     //cube(0.5,0.5,0.5,1,1);
  1770.     ///classrooms
  1771.     classroom1(0);
  1772.     glPushMatrix();
  1773.     glTranslatef(0,0,60);
  1774.  
  1775.     classroom1(2);
  1776.     glRotatef(180,0,1,0);
  1777.     glPopMatrix();
  1778.  
  1779.     ///Main Door
  1780.     glPushMatrix();
  1781.     //glScalef(10,20,1);
  1782.     door(0,5,35,0,10,20);
  1783.     glPopMatrix();
  1784.  
  1785.     rodshape1(45,15,45);
  1786.     rodshape2(45,15,105);
  1787.     spotlightshape(-45,15,45);
  1788.     glEnable(GL_LIGHTING);
  1789.     glPushMatrix();
  1790.     light1(45,15,45);
  1791.     glPopMatrix();
  1792.     glDisable(GL_LIGHTING);
  1793.     glEnable(GL_LIGHTING);
  1794.     glPushMatrix();
  1795.     light2(45,15,105);
  1796.     glPopMatrix();
  1797.     glDisable(GL_LIGHTING);
  1798.     glEnable(GL_LIGHTING);
  1799.     glPushMatrix();
  1800.     light3(-45,15,45);
  1801.     glPopMatrix();
  1802.     glDisable(GL_LIGHTING);
  1803.     //light3();
  1804.  
  1805.     ///Labs
  1806.     lab();
  1807.  
  1808.     ///Sports Room
  1809.     sports();
  1810.     ///Cars
  1811.     glPushMatrix();
  1812.     glTranslatef(15,0,12);
  1813.     car();
  1814.     glPopMatrix();
  1815.     glPushMatrix();
  1816.     glTranslatef(15,0,7);
  1817.     car();
  1818.     glPopMatrix();
  1819.  
  1820.     ///Main Road
  1821.     glEnable(GL_TEXTURE_2D);
  1822.     glBindTexture(GL_TEXTURE_2D,1);
  1823.     glPushMatrix();
  1824.     glScalef(10,0.2,70);
  1825.     glTranslatef(-0.5,-0.5,-0.5);
  1826.     cube(1,1,1);
  1827.     glPopMatrix();
  1828.     glDisable(GL_TEXTURE_2D);
  1829.  
  1830.     ///Grass
  1831.     glEnable(GL_TEXTURE_2D);
  1832.     glBindTexture(GL_TEXTURE_2D,2);
  1833.     glPushMatrix();
  1834.     glScalef(200,0.1,250);
  1835.     glTranslatef(-0.5,-0.5,-0.5);
  1836.     cube(1,1,1);
  1837.     glPopMatrix();
  1838.     glDisable(GL_TEXTURE_2D);
  1839.  
  1840.     fence();
  1841.  
  1842.     building();
  1843.  
  1844.     ///Name plate
  1845.     glEnable(GL_TEXTURE_2D);
  1846.     glBindTexture(GL_TEXTURE_2D,20);
  1847.     glPushMatrix();
  1848.     glTranslatef(0,17.5,35);
  1849.     glScalef(10,5,1);
  1850.     glTranslatef(-0.5,-0.5,-0.5);
  1851.     cube(1,1,1);
  1852.     glPopMatrix();
  1853.     glDisable(GL_TEXTURE_2D);
  1854.  
  1855.  
  1856.     ///Football Field
  1857.     glEnable(GL_TEXTURE_2D);
  1858.     glBindTexture(GL_TEXTURE_2D,6);
  1859.     glPushMatrix();
  1860.     glTranslatef(0,0,75);
  1861.     glScalef(40,0.3,30);
  1862.     glTranslatef(-0.5,-0.5,-0.5);
  1863.     cube(1,1,1);
  1864.     glPopMatrix();
  1865.     glDisable(GL_TEXTURE_2D);
  1866.  
  1867.     ///Floor
  1868.     glEnable(GL_TEXTURE_2D);
  1869.     glBindTexture(GL_TEXTURE_2D,7);
  1870.     glPushMatrix();
  1871.     glTranslatef(0,0,75);
  1872.     glScalef(90,0.2,80);
  1873.     glTranslatef(-0.5,-0.5,-0.5);
  1874.     cube(1,1,1);
  1875.     glPopMatrix();
  1876.     glDisable(GL_TEXTURE_2D);
  1877.  
  1878.     ///Rooves
  1879.     //cover();
  1880.  
  1881.     ///GoalPosts
  1882.     goalpost();
  1883.  
  1884.  
  1885.     trees();
  1886.  
  1887.     teachers();
  1888.  
  1889.     glutSwapBuffers();
  1890.  
  1891.  
  1892.  
  1893. }
  1894.  
  1895. void animate()
  1896. {
  1897.  
  1898.  
  1899.     glutPostRedisplay();
  1900. }
  1901.  
  1902.  
  1903. static void key(unsigned char key, int x, int y)
  1904. {
  1905.     switch (key)
  1906.     {
  1907.     case 27 :
  1908.     case 'q':
  1909.         exit(0);
  1910.         break;
  1911.     case 'f':
  1912.         isrot^=1;
  1913.         break;
  1914.     case 'w':
  1915.         eyeZ++;
  1916.         lookZ++;
  1917.         break;
  1918.     case 's':
  1919.         eyeZ--;
  1920.         lookZ--;
  1921.         break;
  1922.     case 'a':
  1923.         eyeX++;
  1924.         lookX++;
  1925.         break;
  1926.     case 'd':
  1927.         eyeX--;
  1928.         lookX--;
  1929.         break;
  1930.     case 'u':
  1931.         eyeY++;
  1932.         lookY++;
  1933.         break;
  1934.     case 'j':
  1935.         eyeY--;
  1936.         lookY--;
  1937.         break;
  1938.     case '.':
  1939.         rot--;
  1940.         break;
  1941.     case ',':
  1942.         rot++;
  1943.         break;
  1944.     case 'i':
  1945.         eyeY++;
  1946.         break;
  1947.     case 'k':
  1948.         eyeY--;
  1949.         break;
  1950.     case 'r':
  1951.         rot=rot+90;
  1952.         break;
  1953.     case 'z':
  1954.         press1^=1;
  1955.         break;
  1956.     case 'x':
  1957.         press2^=1;
  1958.         break;
  1959.     case 'c':
  1960.         press4^=1;
  1961.         break;
  1962.     case 'v':
  1963.         lookX++;
  1964.         break;
  1965.     case 'b':
  1966.         lookX--;
  1967.         break;
  1968.     case '0':
  1969.         if(da[0]==0)
  1970.             da[0]=1;
  1971.         else
  1972.             da[0]=0;
  1973.         break;
  1974.     case '1':
  1975.         if(da[1]==0)
  1976.             da[1]=1;
  1977.         else
  1978.             da[1]=0;
  1979.         break;
  1980.     case '2':
  1981.         if(da[2]==0)
  1982.             da[2]=1;
  1983.         else
  1984.             da[2]=0;
  1985.         break;
  1986.     case '3':
  1987.         if(da[3]==0)
  1988.             da[3]=1;
  1989.         else
  1990.             da[3]=0;
  1991.         break;
  1992.     case '4':
  1993.         if(da[4]==0)
  1994.             da[4]=1;
  1995.         else
  1996.             da[4]=0;
  1997.         break;
  1998.     case '5':
  1999.         if(da[5]==0)
  2000.             da[5]=1;
  2001.         else
  2002.             da[5]=0;
  2003.         break;
  2004.     case '6':
  2005.         if(da[6]==0)
  2006.             da[6]=1;
  2007.         else
  2008.             da[6]=0;
  2009.         break;
  2010.  
  2011.     }
  2012.  
  2013.     glutPostRedisplay();
  2014. }
  2015.  
  2016. static void idle(void)
  2017. {
  2018.  
  2019.     if (isrot)
  2020.     {
  2021.         spin=spin+1.0;
  2022.  
  2023.         if(spin > 360)
  2024.             spin = 0;
  2025.     }
  2026.     glutPostRedisplay();
  2027. }
  2028.  
  2029.  
  2030.  
  2031.  
  2032. int main(int argc, char *argv[])
  2033. {
  2034.     glutInit(&argc, argv);
  2035.     glutInitWindowSize(width,height);
  2036.     glutInitWindowPosition(10,10);
  2037.     glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  2038.  
  2039.  
  2040.  
  2041.     glutCreateWindow("1607006");
  2042.     //glDisable(GL_LIGHTING);
  2043.     glutDisplayFunc(display);
  2044.     glutKeyboardFunc(key);
  2045.  
  2046.     //glutIdleFunc(animate);
  2047.     //glutSpecialFunc(collision);
  2048.     glutIdleFunc(idle);
  2049.  
  2050.     //glutReshapeFunc(res);
  2051.  
  2052. //    glClearColor(1,1,1,1);
  2053.  
  2054.     glEnable(GL_DEPTH_TEST);
  2055.  
  2056.     glShadeModel( GL_SMOOTH );
  2057.     glEnable(GL_NORMALIZE);
  2058.     glEnable(GL_BLEND);
  2059.     //glEnable(GL_LIGHTING);
  2060.  
  2061.     printf(" Use 'w' to look up, 's' to look down, 'd' to look right, and 'a' to look left.\n");
  2062.     printf(" Press '1' for right light turn on,\n Press '2' for left light turn on, \n Press '3' to turn on both light, \n Press '4' to turn on spotlight.\n");
  2063.  
  2064.     LoadTexture("C:\\Users\\road.bmp");//1
  2065.     LoadTexture("C:\\Users\\grass.bmp");//2
  2066.     LoadTexture("C:\\Users\\fence.bmp");//3
  2067.     LoadTexture("C:\\Users\\window.bmp");//4
  2068.     LoadTexture("C:\\Users\\brick.bmp");//5
  2069.     LoadTexture("C:\\Users\\football.bmp");//6
  2070.     LoadTexture("C:\\Users\\floor.bmp");//7
  2071.     LoadTexture("C:\\Users\\carlight.bmp");//8
  2072.     LoadTexture("C:\\Users\\topview.bmp");//9
  2073.     LoadTexture("C:\\Users\\pipe.bmp");//10
  2074.     LoadTexture("C:\\Users\\wardrobebody.bmp");//11
  2075.     LoadTexture("C:\\Users\\wardrobefront.bmp");//12
  2076.     LoadTexture("C:\\Users\\chair.bmp");//13
  2077.     LoadTexture("C:\\Users\\clock.bmp");//14
  2078.     LoadTexture("C:\\Users\\carrom.bmp");//15
  2079.     LoadTexture("C:\\Users\\chess.bmp");//16
  2080.     LoadTexture("C:\\Users\\dart.bmp");//17
  2081.     LoadTexture("C:\\Users\\net.bmp");//18
  2082.     LoadTexture("C:\\Users\\door.bmp");//19
  2083.     LoadTexture("C:\\Users\\name.bmp");//20
  2084.     LoadTexture("C:\\Users\\tree.bmp");//21
  2085.  
  2086.     glutMainLoop();
  2087.  
  2088.     return EXIT_SUCCESS;
  2089. }
  2090.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement