1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Clear the colour and depth buffer
glLoadIdentity(); // Clear matrix stack
// We set the camera in position 50,50,100 and we look at origo
gluLookAt(50,50,100,0,0,0,0,1,0);
// Make the model rotate around the y axis.
glRotatef(rot_val,0,1,0);
glColor3f(1,0,0);
glBegin(GL_LINES);
glColor3f(1,0,0);
glVertex3f(0,0,0);
glVertex3f(1000,0,0);
glEnd();
glColor3f(0,1,0);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,1000,0);
glEnd();
glColor3f(0,0,1);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,0,1000);
glEnd();
glPushMatrix();
glTranslatef(-10,0,-10);
// T base
// Draw cube 1
glPushMatrix();
glTranslatef(0,5,25);
glScalef(5,5,50);
drawCube();
glPopMatrix();
// T roof
// Draw cube 2
glPushMatrix();
glTranslatef(0,5,0);
glScalef(30,5,5);
drawCube();
glPopMatrix();
// P base
glPushMatrix();
glTranslatef(30,5,25);
glScalef(5,5,50);
drawCube();
glPopMatrix();
glPushMatrix();
glTranslatef(40,5,0);
glScalef(25,5,5);
drawCube();
glPopMatrix();
glPushMatrix();
glTranslatef(40,5,25);
glScalef(25,5,5);
drawCube();
glPopMatrix();
glPushMatrix();
glTranslatef(50,5,13);
glScalef(5,5,25);
drawCube();
glPopMatrix();
glPopMatrix();
// Draw plane
glPushMatrix();
glScalef(100,100,100);
drawPlane();
glPopMatrix();
glFlush(); // Makes sure that we output the model to the graphics card
glutSwapBuffers();
glutPostRedisplay();
} |
Partager