#Include #Include #Include #Include
#Include #Include #Include #Include
#include
#include
#include
<math.h>
<stdio.h>
<stdlib.h>
<GL/glut.h>
cone = gluNewQuadric();
qsphere = gluNewQuadric();
void make_viewpoint(void)
if (headsUp) {
float width = (1 + 2*(draw_passes/nMirrors)) * 1.25;
float height = (width / tan((30./360.) * (2.*M_PI))) + 1;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(75, 1, height - 3, height + 3);
gluLookAt(0, height, 0,
0, 0, 0,
0, 0, 1);
}
else {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1, .01, 4 + 2*(draw_passes / nMirrors));
gluLookAt(-2, 0, .75,
0, 0, 0,
0, 1, 0);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void reshape(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
make_viewpoint();
}
void draw_room(void)
{
static GLfloat wall_mat[] = {1,1,1,1};
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, wall_mat);
glBegin(GL_QUADS);
glNormal3f(0, 1, 0);
glVertex3f(-1, -1, 1);
glVertex3f(1, -1, 1);
glVertex3f(1, -1, -1);
glVertex3f(-1, -1, -1);
glNormal3f(0, -1, 0);
glVertex3f(-1, 1, -1);
glVertex3f(1, 1, -1);
glVertex3f(1, 1, 1);
glVertex3f(-1, 1, 1);
glNormal3f(1, 0, 0);
glVertex3f(-1, -1, -1);
glVertex3f(-1, 1, -1);
glVertex3f(-1, 1, 1);
glVertex3f(-1, -1, 1);
glNormal3f(-1, 0, 0);
glVertex3f(1,
glVertex3f(1,
glVertex3f(1,
glVertex3f(1,
-1, 1);
1, 1);
1, -1);
-1, -1);
glNormal3f(0, 0, 1);
glVertex3f(-1, -1, -1);
glVertex3f(1, -1, -1);
glVertex3f(1, 1, -1);
glVertex3f(-1, 1, -1);
glNormal3f(0, 0, -1);
glVertex3f(-1, 1, 1);
glVertex3f(1, 1, 1);
glVertex3f(1, -1, 1);
glVertex3f(-1, -1, 1);
glEnd();
}
void draw_cone(void)
{
static GLfloat cone_mat[] = {0.f, .5f, 1.f, 1.f};
glPushMatrix();
glTranslatef(0, -1, 0);
glRotatef(-90, 1, 0, 0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cone_mat);
gluCylinder(cone, 0.3, 0, 1.25, 20, 1);
}
glPopMatrix();
GLdouble get_secs(void)
{
return glutGet(GLUT_ELAPSED_TIME) / 1000.0;
}
}
err = glGetError();
if (err != GL_NO_ERROR) printf("Error: %s\n", gluErrorString(err));
glutSwapBuffers();
switch(id)
{
case 2: glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
break;
case 3: glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
break;
default :break;
}
glutPostRedisplay();
glutMainLoop();
return 0;