/* stairs.c */ /* We use the object view function in the display callback to point the eye, whose position can be altered by the x,X,y,Y,z and Z keys for eye position r,R,p,P,h and H keys for roll, pitch and heading The perspective view is set in the reshape callback */ #include #include #include static GLfloat roll =350.0; static GLfloat pitch =294.0; static GLfloat heading =358.0; static GLfloat width = 900; static GLfloat height = 900; static GLfloat a = 1.8; void objectView() { glRotatef(roll, 0.0, 1.0, 0.0); glRotatef(pitch, 1.0, 0.0, 0.0); glRotatef(heading, 0.0, 0.0, 1.0); } void display(void) { char text2[]="roll, pitch, heading r, R=ddd, p, P=ddd, h, H=ddd"; char rolld[4], pitchd[4], headingd[4]; char *p; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glLoadIdentity(); objectView(); /* draw wall */ glBegin(GL_POLYGON); glColor3f(0.6, 0.5, 0.5); /* gray side 1*/ glVertex3f(-1.0, 1.0, -1.0); glVertex3f( 1.0, 1.0, -1.0); glVertex3f( 1.0, 1.0, 1.0); glVertex3f( 0.8, 1.0, 1.0); glVertex3f( 0.6, 1.0, 0.96); glVertex3f( 0.6, 1.0, 1.0); glVertex3f( 0.4, 1.0, 0.96); glVertex3f( 0.4, 1.0, 1.0); glVertex3f( 0.2, 1.0, 0.96); glVertex3f( 0.2, 1.0, 1.0); glVertex3f( 0.0, 1.0, 0.96); glVertex3f( 0.0, 1.0, 1.0); glVertex3f(-0.2, 1.0, 0.96); glVertex3f(-0.2, 1.0, 1.0); glVertex3f(-0.4, 1.0, 0.96); glVertex3f(-0.4, 1.0, 1.0); glVertex3f(-0.6, 1.0, 0.96); glVertex3f(-0.6, 1.0, 1.0); glVertex3f(-0.8, 1.0, 0.96); glVertex3f(-0.8, 1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); glEnd(); glBegin(GL_POLYGON); /* inside 1 */ glColor3f(0.5, 0.4, 0.4); /* darker */ glVertex3f(-0.8, 0.8, -1.0); glVertex3f( 0.8, 0.8, -1.0); glVertex3f( 0.8, 0.8, 1.0); glVertex3f( 0.6, 0.8, 0.96); glVertex3f( 0.6, 0.8, 1.0); glVertex3f( 0.4, 0.8, 0.96); glVertex3f( 0.4, 0.8, 1.0); glVertex3f( 0.2, 0.8, 0.96); glVertex3f( 0.2, 0.8, 1.0); glVertex3f( 0.0, 0.8, 0.96); glVertex3f( 0.0, 0.8, 1.0); glVertex3f(-0.2, 0.8, 0.96); glVertex3f(-0.2, 0.8, 1.0); glVertex3f(-0.4, 0.8, 0.96); glVertex3f(-0.4, 0.8, 1.0); glVertex3f(-0.6, 0.8, 0.96); glVertex3f(-0.6, 0.8, 1.0); glVertex3f(-0.8, 0.8, 0.96); glVertex3f(-0.8, 0.8, 1.0); glEnd(); glColor3f(0.8, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 1.0, 1.0); glVertex3f( 0.8, 1.0, 1.0); glVertex3f( 0.8, 0.8, 1.0); glVertex3f( 1.0, 0.8, 1.0); glEnd(); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.8, 1.0, 1.0); glVertex3f( 0.6, 1.0, 0.96); glVertex3f( 0.6, 0.8, 0.96); glVertex3f( 0.8, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.6, 1.0, 1.0); glVertex3f( 0.6, 1.0, 0.96); glVertex3f( 0.6, 0.8, 0.96); glVertex3f( 0.6, 0.8, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glVertex3f( 0.6, 1.0, 1.0); glVertex3f( 0.4, 1.0, 0.96); glVertex3f( 0.4, 0.8, 0.96); glVertex3f( 0.6, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.4, 1.0, 1.0); glVertex3f( 0.4, 1.0, 0.96); glVertex3f( 0.4, 0.8, 0.96); glVertex3f( 0.4, 0.8, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glVertex3f( 0.4, 1.0, 1.0); glVertex3f( 0.2, 1.0, 0.96); glVertex3f( 0.2, 0.8, 0.96); glVertex3f( 0.4, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.2, 1.0, 1.0); glVertex3f( 0.2, 1.0, 0.96); glVertex3f( 0.2, 0.8, 0.96); glVertex3f( 0.2, 0.8, 1.0); glEnd(); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.2, 1.0, 1.0); glVertex3f( 0.0, 1.0, 0.96); glVertex3f( 0.0, 0.8, 0.96); glVertex3f( 0.2, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.0, 1.0, 1.0); glVertex3f( 0.0, 1.0, 0.96); glVertex3f( 0.0, 0.8, 0.96); glVertex3f( 0.0, 0.8, 1.0); glEnd(); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f( 0.0, 1.0, 1.0); glVertex3f(-0.2, 1.0, 0.96); glVertex3f(-0.2, 0.8, 0.96); glVertex3f( 0.0, 0.8, 1.00); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.2, 1.0, 1.0); glVertex3f(-0.2, 1.0, 0.96); glVertex3f(-0.2, 0.8, 0.96); glVertex3f(-0.2, 0.8, 1.0); glEnd(); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.2, 1.0, 1.0); glVertex3f(-0.4, 1.0, 0.96); glVertex3f(-0.4, 0.8, 0.96); glVertex3f(-0.2, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.4, 1.0, 1.0); glVertex3f(-0.4, 1.0, 0.96); glVertex3f(-0.4, 0.8, 0.96); glVertex3f(-0.4, 0.8, 1.0); glEnd(); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.4, 1.0, 1.0); glVertex3f(-0.6, 1.0, 0.96); glVertex3f(-0.6, 0.8, 0.96); glVertex3f(-0.4, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.6, 1.0, 1.0); glVertex3f(-0.6, 1.0, 0.96); glVertex3f(-0.6, 0.8, 0.96); glVertex3f(-0.6, 0.8, 1.0); glEnd(); glColor3f(0.7, 0.5, 0.5); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.6, 1.0, 1.0); glVertex3f(-0.8, 1.0, 0.96); glVertex3f(-0.8, 0.8, 0.96); glVertex3f(-0.6, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.4, 0.4); /* gray top 1*/ glBegin(GL_POLYGON); glVertex3f(-0.8, 1.0, 1.0); glVertex3f(-0.8, 1.0, 0.96); glVertex3f(-0.8, 0.8, 0.96); glVertex3f(-0.8, 0.8, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3f(0.5, 0.6, 0.5); /* gray side 3*/ glVertex3f(-1.0, -1.0, -1.0); glVertex3f( 1.0, -1.0, -1.0); glVertex3f( 1.0, -1.0, 1.0); glVertex3f( 0.8, -1.0, 1.0); glVertex3f( 0.8, -1.0, 0.96); glVertex3f( 0.6, -1.0, 1.0); glVertex3f( 0.6, -1.0, 0.96); glVertex3f( 0.4, -1.0, 1.0); glVertex3f( 0.4, -1.0, 0.96); glVertex3f( 0.2, -1.0, 1.0); glVertex3f( 0.2, -1.0, 0.96); glVertex3f( 0.0, -1.0, 1.0); glVertex3f( 0.0, -1.0, 0.96); glVertex3f(-0.2, -1.0, 1.0); glVertex3f(-0.2, -1.0, 0.96); glVertex3f(-0.4, -1.0, 1.0); glVertex3f(-0.4, -1.0, 0.96); glVertex3f(-0.6, -1.0, 1.0); glVertex3f(-0.6, -1.0, 0.96); glVertex3f(-0.8, -1.0, 1.0); glVertex3f(-1.0, -1.0, 1.0); glEnd(); glBegin(GL_POLYGON); /* inside 3 */ glColor3f(0.4, 0.5, 0.4); /* darker */ glVertex3f(-0.8, -0.8, -1.0); glVertex3f( 0.8, -0.8, -1.0); glVertex3f( 0.8, -0.8, 0.96); glVertex3f( 0.6, -0.8, 1.0); glVertex3f( 0.6, -0.8, 0.96); glVertex3f( 0.4, -0.8, 1.0); glVertex3f( 0.4, -0.8, 0.96); glVertex3f( 0.2, -0.8, 1.0); glVertex3f( 0.2, -0.8, 0.96); glVertex3f( 0.0, -0.8, 1.0); glVertex3f( 0.0, -0.8, 0.96); glVertex3f(-0.2, -0.8, 1.0); glVertex3f(-0.2, -0.8, 0.96); glVertex3f(-0.4, -0.8, 1.0); glVertex3f(-0.4, -0.8, 0.96); glVertex3f(-0.6, -0.8, 1.0); glVertex3f(-0.6, -0.8, 0.96); glVertex3f(-0.8, -0.8, 1.0); glVertex3f(-0.8, -0.8, 0.96); glEnd(); glColor3f(0.5, 0.8, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( -1.0, -1.0, 1.0); glVertex3f( -0.8, -1.0, 1.0); glVertex3f( -0.8, -0.8, 1.0); glVertex3f( -1.0, -0.8, 1.0); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.8, -1.0, 1.0); glVertex3f( 0.8, -1.0, 0.96); glVertex3f( 0.8, -0.8, 0.96); glVertex3f( 0.8, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.8, -1.0, 0.96); glVertex3f( 0.6, -1.0, 1.0); glVertex3f( 0.6, -0.8, 1.0); glVertex3f( 0.8, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.6, -1.0, 1.0); glVertex3f( 0.6, -1.0, 0.96); glVertex3f( 0.6, -0.8, 0.96); glVertex3f( 0.6, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.6, -1.0, 0.96); glVertex3f( 0.4, -1.0, 1.0); glVertex3f( 0.4, -0.8, 1.0); glVertex3f( 0.6, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.4, -1.0, 1.0); glVertex3f( 0.4, -1.0, 0.96); glVertex3f( 0.4, -0.8, 0.96); glVertex3f( 0.4, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.4, -1.0, 0.96); glVertex3f( 0.2, -1.0, 1.0); glVertex3f( 0.2, -0.8, 1.0); glVertex3f( 0.4, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.2, -1.0, 1.0); glVertex3f( 0.2, -1.0, 0.96); glVertex3f( 0.2, -0.8, 0.96); glVertex3f( 0.2, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.2, -1.0, 0.96); glVertex3f( 0.0, -1.0, 1.0); glVertex3f( 0.0, -0.8, 1.0); glVertex3f( 0.2, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.0, -1.0, 1.0); glVertex3f( 0.0, -1.0, 0.96); glVertex3f( 0.0, -0.8, 0.96); glVertex3f( 0.0, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f( 0.0, -1.0, 0.96); glVertex3f(-0.2, -1.0, 1.0); glVertex3f(-0.2, -0.8, 1.0); glVertex3f( 0.0, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.2, -1.0, 1.0); glVertex3f(-0.2, -1.0, 0.96); glVertex3f(-0.2, -0.8, 0.96); glVertex3f(-0.2, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.2, -1.0, 0.96); glVertex3f(-0.4, -1.0, 1.0); glVertex3f(-0.4, -0.8, 1.0); glVertex3f(-0.2, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.4, -1.0, 1.0); glVertex3f(-0.4, -1.0, 0.96); glVertex3f(-0.4, -0.8, 0.96); glVertex3f(-0.4, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.4, -1.0, 0.96); glVertex3f(-0.6, -1.0, 1.0); glVertex3f(-0.6, -0.8, 1.0); glVertex3f(-0.4, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.6, -1.0, 1.0); glVertex3f(-0.6, -1.0, 0.96); glVertex3f(-0.6, -0.8, 0.96); glVertex3f(-0.6, -0.8, 1.0); glEnd(); glColor3f(0.5, 0.7, 0.5); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.6, -1.0, 0.96); glVertex3f(-0.8, -1.0, 1.0); glVertex3f(-0.8, -0.8, 1.0); glVertex3f(-0.6, -0.8, 0.96); glEnd(); glColor3f(0.4, 0.6, 0.4); /* gray top 3*/ glBegin(GL_POLYGON); glVertex3f(-0.8, -1.0, 1.0); glVertex3f(-0.8, -1.0, 0.96); glVertex3f(-0.8, -0.8, 0.96); glVertex3f(-0.8, -0.8, 1.0); glEnd(); glBegin(GL_POLYGON); glColor3f(0.5, 0.5, 0.6); /* gray side 2 */ glVertex3f( 1.0, -1.0, -1.0); glVertex3f( 1.0, 1.0, -1.0); glVertex3f( 1.0, 1.0, 1.0); glVertex3f( 1.0, 0.8, 1.00); glVertex3f( 1.0, 0.8, 0.96); glVertex3f( 1.0, 0.6, 1.0); glVertex3f( 1.0, 0.6, 0.96); glVertex3f( 1.0, 0.4, 1.0); glVertex3f( 1.0, 0.4, 0.96); glVertex3f( 1.0, 0.2, 1.0); glVertex3f( 1.0, 0.2, 0.96); glVertex3f( 1.0, 0.0, 1.0); glVertex3f( 1.0, 0.0, 0.96); glVertex3f( 1.0, -0.2, 1.0); glVertex3f( 1.0, -0.2, 0.96); glVertex3f( 1.0, -0.4, 1.0); glVertex3f( 1.0, -0.4, 0.96); glVertex3f( 1.0, -0.6, 1.0); glVertex3f( 1.0, -0.6, 0.96); glVertex3f( 1.0, -0.8, 1.0); glVertex3f( 1.0, -1.0, 1.0); glEnd(); glBegin(GL_POLYGON); /* inside 2 */ glColor3f(0.4, 0.4, 0.5); /* darker */ glVertex3f( 0.8, -0.8, -1.0); glVertex3f( 0.8, 0.8, -1.0); glVertex3f( 0.8, 0.8, 0.96); glVertex3f( 0.8, 0.6, 1.0); glVertex3f( 0.8, 0.6, 0.96); glVertex3f( 0.8, 0.4, 1.0); glVertex3f( 0.8, 0.4, 0.96); glVertex3f( 0.8, 0.2, 1.0); glVertex3f( 0.8, 0.2, 0.96); glVertex3f( 0.8, 0.0, 1.0); glVertex3f( 0.8, 0.0, 0.96); glVertex3f( 0.8, -0.2, 1.0); glVertex3f( 0.8, -0.2, 0.96); glVertex3f( 0.8, -0.4, 1.0); glVertex3f( 0.8, -0.4, 0.96); glVertex3f( 0.8, -0.6, 1.0); glVertex3f( 0.8, -0.6, 0.96); glVertex3f( 0.8, -0.8, 1.0); glVertex3f( 0.8, -0.8, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.8); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -1.0, 1.0); glVertex3f( 1.0, -0.8, 1.0); glVertex3f( 0.8, -0.8, 1.0); glVertex3f( 0.8, -1.0, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.8, 1.0); glVertex3f( 0.8, 0.8, 1.0); glVertex3f( 0.8, 0.8, 0.96); glVertex3f( 1.0, 0.8, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.8, 0.96); glVertex3f( 1.0, 0.6, 1.0); glVertex3f( 0.8, 0.6, 1.0); glVertex3f( 0.8, 0.8, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.6, 1.0); glVertex3f( 0.8, 0.6, 1.0); glVertex3f( 0.8, 0.6, 0.96); glVertex3f( 1.0, 0.6, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.6, 0.96); glVertex3f( 1.0, 0.4, 1.0); glVertex3f( 0.8, 0.4, 1.0); glVertex3f( 0.8, 0.6, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.4, 1.0); glVertex3f( 0.8, 0.4, 1.0); glVertex3f( 0.8, 0.4, 0.96); glVertex3f( 1.0, 0.4, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.4, 0.96); glVertex3f( 1.0, 0.2, 1.0); glVertex3f( 0.8, 0.2, 1.0); glVertex3f( 0.8, 0.4, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.2, 1.0); glVertex3f( 0.8, 0.2, 1.0); glVertex3f( 0.8, 0.2, 0.96); glVertex3f( 1.0, 0.2, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.2, 0.96); glVertex3f( 1.0, 0.0, 1.0); glVertex3f( 0.8, 0.0, 1.0); glVertex3f( 0.8, 0.2, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, 0.0, 1.0); glVertex3f( 0.8, 0.0, 1.0); glVertex3f( 0.8, 0.0, 0.96); glVertex3f( 1.0, 0.0, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.0, 0.96); glVertex3f( 1.0, -0.2, 1.0); glVertex3f( 0.8, -0.2, 1.0); glVertex3f( 0.8, -0.0, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.2, 1.0); glVertex3f( 0.8, -0.2, 1.0); glVertex3f( 0.8, -0.2, 0.96); glVertex3f( 1.0, -0.2, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.2, 0.96); glVertex3f( 1.0, -0.4, 1.0); glVertex3f( 0.8, -0.4, 1.0); glVertex3f( 0.8, -0.2, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.4, 1.0); glVertex3f( 0.8, -0.4, 1.0); glVertex3f( 0.8, -0.4, 0.96); glVertex3f( 1.0, -0.4, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.4, 0.96); glVertex3f( 1.0, -0.6, 1.0); glVertex3f( 0.8, -0.6, 1.0); glVertex3f( 0.8, -0.4, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.6, 1.0); glVertex3f( 0.8, -0.6, 1.0); glVertex3f( 0.8, -0.6, 0.96); glVertex3f( 1.0, -0.6, 0.96); glEnd(); glColor3f(0.5, 0.5, 0.7); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.6, 0.96); glVertex3f( 1.0, -0.8, 1.0); glVertex3f( 0.8, -0.8, 1.0); glVertex3f( 0.8, -0.6, 0.96); glEnd(); glColor3f(0.4, 0.4, 0.6); /* gray top 2*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -0.8, 1.0); glVertex3f( 0.8, -0.8, 1.0); glVertex3f( 0.8, -0.8, 0.96); glVertex3f( 1.0, -0.8, 0.96); glEnd(); glBegin(GL_POLYGON); glColor3f(0.5, 0.5, 0.5); /* gray side 4 */ glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, 1.0, -1.0); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(-1.0, 0.8, 1.0); glVertex3f(-1.0, 0.6, 0.96); glVertex3f(-1.0, 0.6, 1.0); glVertex3f(-1.0, 0.4, 0.96); glVertex3f(-1.0, 0.4, 1.0); glVertex3f(-1.0, 0.2, 0.96); glVertex3f(-1.0, 0.2, 1.0); glVertex3f(-1.0, 0.0, 0.96); glVertex3f(-1.0, 0.0, 1.0); glVertex3f(-1.0, -0.2, 0.96); glVertex3f(-1.0, -0.2, 1.0); glVertex3f(-1.0, -0.4, 0.96); glVertex3f(-1.0, -0.4, 1.0); glVertex3f(-1.0, -0.6, 0.96); glVertex3f(-1.0, -0.6, 1.0); glVertex3f(-1.0, -0.8, 0.96); glVertex3f(-1.0, -0.8, 1.0); glVertex3f(-1.0, -1.0, 1.0); glEnd(); glBegin(GL_POLYGON); /* inside */ glColor3f(0.3, 0.3, 0.3); /* darker */ glVertex3f(-0.8, -0.8, -1.0); glVertex3f(-0.8, 0.8, -1.0); glVertex3f(-0.8, 0.8, 1.0); glVertex3f(-0.8, 0.6, 0.96); glVertex3f(-0.8, 0.6, 1.0); glVertex3f(-0.8, 0.4, 0.96); glVertex3f(-0.8, 0.4, 1.0); glVertex3f(-0.8, 0.2, 0.96); glVertex3f(-0.8, 0.2, 1.0); glVertex3f(-0.8, 0.0, 0.96); glVertex3f(-0.8, 0.0, 1.0); glVertex3f(-0.8, -0.2, 0.96); glVertex3f(-0.8, -0.2, 1.0); glVertex3f(-0.8, -0.4, 0.96); glVertex3f(-0.8, -0.4, 1.0); glVertex3f(-0.8, -0.6, 0.96); glVertex3f(-0.8, -0.6, 1.0); glVertex3f(-0.8, -0.8, 0.96); glVertex3f(-0.8, -0.8, 1.0); glEnd(); glColor3f(0.7, 0.7, 0.7); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 1.0, 1.0); glVertex3f(-0.8, 1.0, 1.0); glVertex3f(-0.8, 0.8, 1.0); glVertex3f(-1.0, 0.8, 1.0); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.8, 1.0); glVertex3f(-1.0, 0.6, 0.96); glVertex3f(-0.8, 0.6, 0.96); glVertex3f(-0.8, 0.8, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.6, 1.0); glVertex3f(-0.8, 0.6, 1.0); glVertex3f(-0.8, 0.6, 0.96); glVertex3f(-1.0, 0.6, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.6, 1.0); glVertex3f(-1.0, 0.4, 0.96); glVertex3f(-0.8, 0.4, 0.96); glVertex3f(-0.8, 0.6, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.4, 1.0); glVertex3f(-0.8, 0.4, 1.0); glVertex3f(-0.8, 0.4, 0.96); glVertex3f(-1.0, 0.4, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.4, 1.0); glVertex3f(-1.0, 0.2, 0.96); glVertex3f(-0.8, 0.2, 0.96); glVertex3f(-0.8, 0.4, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.2, 1.0); glVertex3f(-0.8, 0.2, 1.0); glVertex3f(-0.8, 0.2, 0.96); glVertex3f(-1.0, 0.2, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.2, 1.0); glVertex3f(-1.0, 0.0, 0.96); glVertex3f(-0.8, 0.0, 0.96); glVertex3f(-0.8, 0.2, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, 0.0, 1.0); glVertex3f(-0.8, 0.0, 1.0); glVertex3f(-0.8, 0.0, 0.96); glVertex3f(-1.0, 0.0, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.0, 1.0); glVertex3f(-1.0, -0.2, 0.96); glVertex3f(-0.8, -0.2, 0.96); glVertex3f(-0.8, -0.0, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.2, 1.0); glVertex3f(-0.8, -0.2, 1.0); glVertex3f(-0.8, -0.2, 0.96); glVertex3f(-1.0, -0.2, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.2, 1.0); glVertex3f(-1.0, -0.4, 0.96); glVertex3f(-0.8, -0.4, 0.96); glVertex3f(-0.8, -0.2, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.4, 1.0); glVertex3f(-0.8, -0.4, 1.0); glVertex3f(-0.8, -0.4, 0.96); glVertex3f(-1.0, -0.4, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.4, 1.0); glVertex3f(-1.0, -0.6, 0.96); glVertex3f(-0.8, -0.6, 0.96); glVertex3f(-0.8, -0.4, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.6, 1.0); glVertex3f(-0.8, -0.6, 1.0); glVertex3f(-0.8, -0.6, 0.96); glVertex3f(-1.0, -0.6, 0.96); glEnd(); glColor3f(0.6, 0.6, 0.6); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.6, 1.0); glVertex3f(-1.0, -0.8, 0.96); glVertex3f(-0.8, -0.8, 0.96); glVertex3f(-0.8, -0.6, 1.0); glEnd(); glColor3f(0.4, 0.4, 0.4); /* gray top 4*/ glBegin(GL_POLYGON); glVertex3f(-1.0, -0.8, 1.0); glVertex3f(-0.8, -0.8, 1.0); glVertex3f(-0.8, -0.8, 0.96); glVertex3f(-1.0, -0.8, 0.96); glEnd(); /* bottom */ glColor3f(0.2, 0.2, 0.2); /* gray bottom*/ glBegin(GL_POLYGON); glVertex3f( 1.0, -1.0, -1.0); glVertex3f(-1.0, -1.0, -1.0); glVertex3f(-1.0, 1.0, -1.0); glVertex3f( 1.0, 1.0, -1.0); glEnd(); glPopMatrix(); glPushMatrix(); glLoadIdentity(); glColor3f(1.0, 1.0, 1.0); glTranslatef(-a+0.05, -a+0.05, 0.0); glScalef(0.001, 0.001, 1.0); sprintf(rolld,"%3d",(int)roll); text2[27]=rolld[0]; text2[28]=rolld[1]; text2[29]=rolld[2]; sprintf(pitchd,"%3d",(int)pitch); text2[37]=pitchd[0]; text2[38]=pitchd[1]; text2[39]=pitchd[2]; sprintf(headingd,"%3d",(int)heading); text2[47]=headingd[0]; text2[48]=headingd[1]; text2[49]=headingd[2]; for(p=text2; *p; p++) glutStrokeCharacter(GLUT_STROKE_ROMAN, *p); glPopMatrix(); glFlush(); glutSwapBuffers(); } void keys(unsigned char key, int x, int y) { /* Use r, R, p, P, h, and H keys to move roll, pitch, heading */ if(key == 'r') {roll -= 2.0; if(roll<0.0) roll=358.0; } if(key == 'R') {roll += 2.0; if(roll>360.0) roll=2.0; } if(key == 'p') {pitch -= 2.0; if(pitch<0.0) pitch=358.0; } if(key == 'P') {pitch += 2.0; if(pitch>360.0) pitch=2.0; } if(key == 'h') {heading -= 2.0; if(heading<0.0) heading=358.0; } if(key == 'H') {heading += 2.0; if(heading>360.0) heading=2.0; } display(); } void myReshape(int w, int h) { glViewport(0, 0, w, h); /* Use a perspective view */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-a, a, -a, a, -a, a); glMatrixMode(GL_MODELVIEW); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(width, height); glutCreateWindow(argv[0]); glutReshapeFunc(myReshape); glutDisplayFunc(display); glutKeyboardFunc(keys); glEnable(GL_DEPTH_TEST); glutMainLoop(); return 0; }