void renderScene(void) { if (deltaMove || lstrafe || rstrafe) computePos(deltaMove); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(102.0/255.0, 204.0/255.0, 1.0f, 1.0f); glLoadIdentity(); gluLookAt( x, 1.0f, z, x+lx, 1.0+ly, z+lz, 0.0f, 1.0f, 0.0f); glColor3f(0.0f, 0.65f, 0.0f); glBegin(GL_QUADS); glVertex3f(-100.0f, 0.0f, -100.0f); glVertex3f(-100.0f, 0.0f, 100.0f); glVertex3f( 100.0f, 0.0f, 100.0f); glVertex3f( 100.0f, 0.0f, -100.0f); glEnd(); int i,j; //Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(29.6,0,30); drawDoorZ(); glPopMatrix(); //Door attached wall r = 0.9, g = 0.9, b = 0.9; glPushMatrix(); glTranslatef(33,0,30.6); drawWallX(10); glPopMatrix(); //Door attached wall glPushMatrix(); glTranslatef(26.6,0,30); drawWallZ(3); glPopMatrix(); //Living room wall glPushMatrix(); glTranslatef(26.6,0,30); drawWallX(-5); glPopMatrix(); //Long living room wall glPushMatrix(); glTranslatef(26.6,0,25); drawWallZ(-30); glPopMatrix(); //Balcony to hall living room connector glPushMatrix(); glTranslatef(-3.4,0,40); drawWallZ(15); glPopMatrix(); //Balcony parapet r = 0.0, g = 0.0, b = 0.0; glPushMatrix(); glTranslatef(-9.6,0,25.65); drawParapetX(14.2); glPopMatrix(); r = 0.9, g = 0.9, b = 0.9; //Balcony wall glPushMatrix(); glTranslatef(-3.4,0,25); drawWallZ(-6); glPopMatrix(); //Balcony wall glPushMatrix(); glTranslatef(-3.4,0,40); drawWallZ(-6); glPopMatrix(); //Balcony slide doors glPushMatrix(); glTranslatef(-3.4,0,25); drawWallX(6); glPopMatrix(); //Balcony slide doors glPushMatrix(); glTranslatef(-3.4,0,34); drawWallX(6); glPopMatrix(); //Shoebox wall glPushMatrix(); glTranslatef(33,0,40); drawWallZ(-6); glPopMatrix(); //Hall wall to bathroom glPushMatrix(); glTranslatef(27,0,40); drawWallX(15); glPopMatrix(); //Hall wall glPushMatrix(); glTranslatef(11.6,0,40); drawWallX(25); glPopMatrix(); //Bathroom Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(27,0,55); drawDoorX(); glPopMatrix(); //Bedroom bathroom separator r = 0.9, g = 0.9, b = 0.9; glPushMatrix(); glTranslatef(27,0,59); drawWallX(1); glPopMatrix(); //Bathroom walls r = 0.0, g = 0.0, b = 0.9; glPushMatrix(); glTranslatef(27.6,0,59); drawWallZ(10); glPopMatrix(); //Bathroom walls glPushMatrix(); glTranslatef(27.6,0,49); drawWallZ(10); glPopMatrix(); //Bathroom walls glPushMatrix(); glTranslatef(37.6,0,59); drawWallX(-10); glPopMatrix(); //Bedroom walls r = 0.9, g = 0.9, b = 0.9; glPushMatrix(); glTranslatef(27.6,0,59.6); drawWallZ(10); glPopMatrix(); //Bedroom walls glPushMatrix(); glTranslatef(37.6,0,59); drawWallX(10); glPopMatrix(); //Bedroom walls glPushMatrix(); glTranslatef(27.6,0,69); drawWallZ(10); glPopMatrix(); //Bedroom walls glPushMatrix(); glTranslatef(27.6,0,69); drawWallX(-4.8); glPopMatrix(); //Bathroom Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(27.6,0,60.2); drawDoorX(); glPopMatrix(); //Bedroom kitchen separator r = 0.9, g = 0.9, b = 0.9; glPushMatrix(); glTranslatef(27.6,0,69); drawWallZ(-5); glPopMatrix(); //Kitchen walls glPushMatrix(); glTranslatef(22.6,0,69); drawWallX(15); glPopMatrix(); //Kitchen walls glPushMatrix(); glTranslatef(22.6,0,84); drawWallZ(-7); glPopMatrix(); //Kitchen walls glPushMatrix(); glTranslatef(15.6,0,84); drawWallX(-15); glPopMatrix(); //Kitchen bedroom separator glPushMatrix(); glTranslatef(15.6,0,69); drawWallZ(-2); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(13.6,0,69); drawWallX(15); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(13.6,0,84); drawWallZ(-15); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(-2.6,0,84); drawWallX(-15); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(-2.6,0,69); drawWallZ(12); glPopMatrix(); //Bedroom Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(9.6,0,69); drawDoorZ(); glPopMatrix(); //Bathroom 2 walls r = 0.9, g = 0.9, b = 0.9; glPushMatrix(); glTranslatef(5.6,0,65); drawWallZ(-13); glPopMatrix(); //Bathroom 2 walls glPushMatrix(); glTranslatef(-7.4,0,65); drawWallX(-6); glPopMatrix(); //Bathroom 2 walls glPushMatrix(); glTranslatef(-7.4,0,59); drawWallZ(19); glPopMatrix(); //Bathroom 2 walls glPushMatrix(); glTranslatef(9.6,0,65); drawWallZ(2); glPopMatrix(); //Bathroom 2 Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(5.59,0,65); drawDoorZ(); glPopMatrix(); //Bedroom 3 walls r = 0.9, g = 0.9, b = 0.9; glPushMatrix(); glTranslatef(-7.4,0,59); drawWallZ(-6); glPopMatrix(); //Bedroom 3 walls glPushMatrix(); glTranslatef(-13.4,0,59); drawWallX(25); glPopMatrix(); //Bedroom 3 walls glPushMatrix(); glTranslatef(-13.4,0,84); drawWallZ(15); glPopMatrix(); //Bedroom 3 Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(-2.6,0,65); drawDoorX(); glPopMatrix(); glPushMatrix(); glTranslatef(-30,0,-30); watersim(); glPopMatrix(); glutSwapBuffers(); }
// Main drawing function void renderScene(void) { // Compute position if we move forward or left or right if (deltaMove || lstrafe || rstrafe) computePos(deltaMove); // Clear color and set background to blue sky glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(102.0/255.0, 204.0/255.0, 1.0f, 1.0f); // Sets up viewing // Eye is at recorded position x, y, z // We are looking in the direction vx, vy, vz // The up vector is in y direction glLoadIdentity(); gluLookAt( x, y, z, x+vx, y+vy, z+vz, 0.0f, 1.0f, 0.0f ); // Roll the camera as required by roll amount glTranslatef(x,y,z); glRotatef(rollamount, vx, vy, vz); glTranslatef(-x, -y, -z); // Draw green grass glColor3f(0.0f, 0.65f, 0.0f); glBegin(GL_QUADS); glVertex3f(-100.0f, 0.0f, -100.0f); glVertex3f(-100.0f, 0.0f, 100.0f); glVertex3f( 100.0f, 0.0f, 100.0f); glVertex3f( 100.0f, 0.0f, -100.0f); glEnd(); // Drawing walls and doors //Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(29.6,0,30); drawDoorZ(); glPopMatrix(); //Door attached wall r = 1.0, g = 1.0, b = 1.0; glPushMatrix(); glTranslatef(33,0,30.6); drawWallX(10); glPopMatrix(); //Door attached wall glPushMatrix(); glTranslatef(26.6,0,30); drawWallZ(3); glPopMatrix(); //Living room wall glPushMatrix(); glTranslatef(26.6,0,30); drawWallX(-5); glPopMatrix(); //Long living room wall glPushMatrix(); glTranslatef(26.6,0,25); drawWallZ(-30); glPopMatrix(); //Balcony to hall living room connector glPushMatrix(); glTranslatef(-3.4,0,40); drawWallZ(15); glPopMatrix(); //Balcony parapet r = 0.0, g = 0.0, b = 0.0; glPushMatrix(); glTranslatef(-9.6,0,25.65); drawParapetX(14.2); glPopMatrix(); r = 1.0, g = 1.0, b = 1.0; //Balcony wall glPushMatrix(); glTranslatef(-3.4,0,25); drawWallZ(-6); glPopMatrix(); //Balcony wall glPushMatrix(); glTranslatef(-3.4,0,40); drawWallZ(-6); glPopMatrix(); //Balcony slide doors glPushMatrix(); glTranslatef(-3.4,0,25); drawWallX(6); glPopMatrix(); //Balcony slide doors glPushMatrix(); glTranslatef(-3.4,0,34); drawWallX(6); glPopMatrix(); //Shoebox wall glPushMatrix(); glTranslatef(33,0,40); drawWallZ(-6); glPopMatrix(); //Hall wall to bathroom glPushMatrix(); glTranslatef(27,0,40); drawWallX(15); glPopMatrix(); //Hall wall glPushMatrix(); glTranslatef(11.6,0,40); drawWallX(25); glPopMatrix(); //Bathroom Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(27,0,55); drawDoorX(); glPopMatrix(); //Bedroom bathroom separator r = 1.0, g = 1.0, b = 1.0; glPushMatrix(); glTranslatef(27,0,59); drawWallX(1); glPopMatrix(); //Bathroom walls r = 0.0, g = 0.0, b = 0.9; glPushMatrix(); glTranslatef(27.6,0,59); drawWallZ(10); glPopMatrix(); //Bathroom walls glPushMatrix(); glTranslatef(27.6,0,49); drawWallZ(10); glPopMatrix(); //Bathroom walls glPushMatrix(); glTranslatef(37.6,0,59); drawWallX(-10); glPopMatrix(); //Bedroom walls r = 1.0, g = 1.0, b = 1.0; glPushMatrix(); glTranslatef(27.6,0,59.6); drawWallZ(10); glPopMatrix(); //Bedroom walls glPushMatrix(); glTranslatef(37.6,0,59); drawWallX(10); glPopMatrix(); //Bedroom walls glPushMatrix(); glTranslatef(27.6,0,69); drawWallZ(10); glPopMatrix(); //Bedroom walls glPushMatrix(); glTranslatef(27.6,0,69); drawWallX(-4.8); glPopMatrix(); //Bathroom Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(27.6,0,60.2); drawDoorX(); glPopMatrix(); //Bedroom kitchen separator r = 1.0, g = 1.0, b = 1.0; glPushMatrix(); glTranslatef(27.6,0,69); drawWallZ(-5); glPopMatrix(); //Kitchen walls glPushMatrix(); glTranslatef(22.6,0,69); drawWallX(15); glPopMatrix(); //Kitchen walls glPushMatrix(); glTranslatef(22.6,0,84); drawWallZ(-7); glPopMatrix(); //Kitchen walls glPushMatrix(); glTranslatef(15.6,0,84); drawWallX(-15); glPopMatrix(); //Kitchen bedroom separator glPushMatrix(); glTranslatef(15.6,0,69); drawWallZ(-2); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(13.6,0,69); drawWallX(15); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(13.6,0,84); drawWallZ(-15); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(-2.6,0,84); drawWallX(-15); glPopMatrix(); //Bedroom 2 walls glPushMatrix(); glTranslatef(-2.6,0,69); drawWallZ(12); glPopMatrix(); //Bedroom Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(9.6,0,69); drawDoorZ(); glPopMatrix(); //Bathroom 2 walls r = 1.0, g = 1.0, b = 1.0; glPushMatrix(); glTranslatef(5.6,0,65); drawWallZ(-13); glPopMatrix(); //Bathroom 2 walls glPushMatrix(); glTranslatef(-7.4,0,65); drawWallX(-6); glPopMatrix(); //Bathroom 2 walls glPushMatrix(); glTranslatef(-7.4,0,59); drawWallZ(19); glPopMatrix(); //Bathroom 2 walls glPushMatrix(); glTranslatef(9.6,0,65); drawWallZ(2); glPopMatrix(); //Bathroom 2 Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(5.59,0,65); drawDoorZ(); glPopMatrix(); //Bedroom 3 walls r = 1.0, g = 1.0, b = 1.0; glPushMatrix(); glTranslatef(-7.4,0,59); drawWallZ(-6); glPopMatrix(); //Bedroom 3 walls glPushMatrix(); glTranslatef(-13.4,0,59); drawWallX(25); glPopMatrix(); //Bedroom 3 walls glPushMatrix(); glTranslatef(-13.4,0,84); drawWallZ(15); glPopMatrix(); //Bedroom 3 Door r = 0.7, g = 0.3, b = 0.3; glPushMatrix(); glTranslatef(-2.6,0,65); drawDoorX(); glPopMatrix(); glPushMatrix(); glTranslatef(-30,0,-30); glPopMatrix(); glutSwapBuffers(); }