コード例 #1
0
ファイル: lab3.cpp プロジェクト: kuanslove/CGprj
void myDisplay(void){
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60.0, 1.0 * screenWidth / screenHeight, 0.1, 100.0);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(cameraX, cameraY, cameraZ, coiX, coiY, coiZ, 0.0, 1.0, 0.0);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  //set the light source properties
  glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient0);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse0);
  glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular0);
  glLightfv(GL_LIGHT0, GL_POSITION, light_position0);

  glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient1);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse1);
  glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular1);
  glLightfv(GL_LIGHT1, GL_POSITION, light_position1);


  //set the remaining light sources	- write your code here
  glLightfv(GL_LIGHT2, GL_AMBIENT, light_ambient2);
  glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse2);
  glLightfv(GL_LIGHT2, GL_SPECULAR, light_specular2);
  glLightfv(GL_LIGHT2, GL_POSITION, light_position2);

  glLightfv(GL_LIGHT3, GL_AMBIENT, light_ambient3);
  glLightfv(GL_LIGHT3, GL_DIFFUSE, light_diffuse3);
  glLightfv(GL_LIGHT3, GL_SPECULAR, light_specular3);
  glLightfv(GL_LIGHT3, GL_POSITION, light_position3);

  glLightfv(GL_LIGHT4, GL_AMBIENT, light_ambient4);
  glLightfv(GL_LIGHT4, GL_DIFFUSE, light_diffuse4);
  glLightfv(GL_LIGHT4, GL_SPECULAR, light_specular4);
  glLightfv(GL_LIGHT4, GL_POSITION, light_position4);
  //turn on or off the fog - write your code here
if(fogSetting){
    glEnable(GL_FOG);
}
else {
    glDisable(GL_FOG);

}





  glColor3d(0.0, 0.0, 0.0);

/////////////////////////////////////////floor////////////////////////////////////////
  glMaterialfv(GL_FRONT, GL_AMBIENT, floor_ambient);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_diffuse);
  glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular);
  glMaterialfv(GL_FRONT, GL_SHININESS, floor_shininess);

glRotatef(theta,0,1,0);
  //draw the bottom floor
  glPushMatrix();
  glTranslatef(0,floorHeight/2.0,0);
  glScaled(floorWidth, floorHeight, floorWidth);

  glutSolidCube(1.0);
  glPopMatrix();

  //draw the left wall
  glPushMatrix();
  glTranslated(-floorWidth / 2.0, floorWidth / 2.0, 0.0);
  glRotated(90.0, 0.0, 0.0, 1.0);
  glScaled(floorWidth, floorHeight, floorWidth);
  glutSolidCube(1.0);
  glPopMatrix();

  //draw the right wall
  glPushMatrix();
  glTranslated(0.0, floorWidth / 2.0, -floorWidth / 2.0);
  glRotated(90.0, 1.0, 0.0, 0.0);
  glScaled(floorWidth, floorHeight, floorWidth);
  glutSolidCube(1.0);
  glPopMatrix();

  if (textureSetting == ON) glEnable(GL_TEXTURE_2D);

  //map an image texture on the left wall
  glBindTexture(GL_TEXTURE_2D, texImage1Name);
  glBegin(GL_QUADS);
    glNormal3f(1.0, 0.0, 0.0);
    glTexCoord2f(0.0, 0.0); glVertex3d(-floorWidth / 2.0 + floorHeight, 1.5, floorWidth / 2.0 - 1.25);
    glTexCoord2f(1.0, 0.0); glVertex3d(-floorWidth / 2.0 + floorHeight, 1.5, -floorWidth / 2.0 + 1.25);
    glTexCoord2f(1.0, 1.0); glVertex3d(-floorWidth / 2.0 + floorHeight, floorWidth - 0.5, -floorWidth / 2.0 + 1.25);
    glTexCoord2f(0.0, 1.0); glVertex3d(-floorWidth / 2.0 + floorHeight, floorWidth - 0.5, floorWidth / 2.0 - 1.25);
  glEnd();

  //map another image texture on the right wall - write your code here
  glBindTexture(GL_TEXTURE_2D, texImage2Name);
  glBegin(GL_QUADS);
    glNormal3f(0.0, 0.0, 1.0);
    glTexCoord2f(0.0, 0.0); glVertex3d(-floorWidth / 2.0 + 0.5, 1.5, -floorWidth / 2.0 + floorHeight);
    glTexCoord2f(1.0, 0.0); glVertex3d( floorWidth / 2.0 - 0.5, 1.5, -floorWidth / 2.0 + floorHeight);
    glTexCoord2f(1.0, 1.0); glVertex3d( floorWidth / 2.0 - 0.5, floorWidth - 0.5,-floorWidth / 2.0 + floorHeight);
    glTexCoord2f(0.0, 1.0); glVertex3d(-floorWidth / 2.0 + 0.5, floorWidth - 0.5,-floorWidth / 2.0 + floorHeight);
  glEnd();
  //map the checkerboard texture on the bottom floor - write your code here






  glBindTexture(GL_TEXTURE_2D, texCheckerBoardName);
  glBegin(GL_QUADS);
    glNormal3f(0.0, 1.0, 0.0);
    glTexCoord2f(0.0, 0.0); glVertex3d(-floorWidth / 2.0 , floorHeight+0.001, floorWidth / 2.0 );
    glTexCoord2f(1.0, 0.0); glVertex3d( floorWidth / 2.0 , floorHeight+0.001, floorWidth / 2.0 );
    glTexCoord2f(1.0, 1.0); glVertex3d( floorWidth / 2.0 , floorHeight+0.001, -floorWidth / 2.0 );
    glTexCoord2f(0.0, 1.0); glVertex3d(-floorWidth / 2.0 , floorHeight+0.001, -floorWidth / 2.0 );
  glEnd();






  if (textureSetting == ON) glDisable(GL_TEXTURE_2D);
//////////////////////////////////////////floor////////////////////////////////////////

  glTranslated(0.0, floorHeight, 0.0);


	//set up furniture (table, chairs) material properties
	glMaterialfv(GL_FRONT, GL_AMBIENT, furniture_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, furniture_diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, furniture_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, furniture_shininess);

	//draw the two chairs - write your code here
    glPushMatrix();
    glTranslatef(-floorWidth / 4.0, 0, floorWidth / 4.0);
    glRotatef(-90,0,1,0);
    chair();
    glPopMatrix();

    glPushMatrix();
    glTranslatef(floorWidth / 4.0, 0, -floorWidth / 4.0);
    chair();
    glPopMatrix();

	//shift to the quad on the floor which the table will be placed
	glPushMatrix();
	glTranslated(-1.0, 0.0, -1.0);

	//draw the table
	drawTable();

	//raise to the table top: all the remaining objects are above the table
	glTranslated(0.0, tableTopHeight, 0.0);

	//set up teapot/teacup material properties - write your code here
	glMaterialfv(GL_FRONT, GL_AMBIENT, teapot_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, teapot_diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, teapot_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, teapot_shininess);
	//draw the teapot - write your code here
	glPushMatrix();
	glTranslatef(0,0.15,0);
	glRotatef(45,0,1,0);
    tpot();
    glPopMatrix();
	//draw the teacup - write your code here
    glPushMatrix();
    glTranslatef(0, 0, tableTopWidth / 4.0);
    tcup();
    glPopMatrix();
    glPushMatrix();
    glTranslatef(tableTopWidth / 4.0, 0, 0);
    tcup();
    glPopMatrix();
	//set up lamp material properties - write your code here
	glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, lamp_diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, lamp_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, lamp_shininess);
	//draw the lamp - write your code here
    glPushMatrix();
    glTranslatef(-tableTopWidth / 4.0, 0, -tableTopWidth / 4.0);
    lamp();
    glPopMatrix();

	glPopMatrix();
	//set up dustbin material properties - write your code here
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glMaterialfv(GL_FRONT, GL_AMBIENT, dustbin_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, dustbin_diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, dustbin_specular);
	glMaterialfv(GL_FRONT, GL_SHININESS, dustbin_shininess);
	//draw the dustbin - write your code here
  glPushMatrix();
  glTranslated(floorWidth / 4.0, dustbinHeight/2.0, floorWidth / 4.0);
  glScaled(dustbinWidth, dustbinHeight, dustbinWidth);
  glutSolidCube(1.0);
  glPopMatrix();
glDisable(GL_BLEND);
  glutSwapBuffers();
}
コード例 #2
0
ファイル: cg200.c プロジェクト: jasongi/teapot
/*
 =======================================================================================================================
    Display function. Where the magic happens and everything is drawn.
 =======================================================================================================================
 */
void display(void)
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	/* adjust for zoom value */
	gluPerspective(50 * zoom, (float) glutGet(GLUT_WINDOW_WIDTH) / (float) glutGet(GLUT_WINDOW_HEIGHT), 0.001, 40.0);
	glMatrixMode(GL_MODELVIEW);

	/* do rotation things */
	alpha = alpha + (float) inc;
	if(alpha > (float) 360.0) alpha -= (float) 360.0;
	beta = beta + (float) inc2;
	if(beta > (float) 360.0) beta -= (float) 360.0;

	/* normalise any normals which aren't in unit form */
	glEnable(GL_NORMALIZE);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/* draw the fog */
	fog();
	glPushMatrix();

	/* translate whole scene so we can actually see it */
	glTranslatef((float) 0.0, -(float) 0.5, -(float) 5);

	/* rotate by rotation values */
	glRotatef(beta, (float) 1.0, (float) 0.0, (float) 0.0);
	glRotatef(-alpha, (float) 0.0, (float) 1.0, (float) 0.0);

	/* it was a bit big... */
	glScalef(0.50, 0.50, 0.50);

	/* set shade mode */
	glShadeModel(shademode);
	glPushMatrix();

	/* draw the floor */
	glScalef(scale * 5, scale * 5, scale * 5);
	glRotatef(180, 0, 1.0, 1.0);
	drawCheck(20, 20, BLUE, YELLOW);	/* draw ground */
	glPopMatrix();

	/* set up the lights */
	glTranslatef(0.3, 0, 1.25);
	glEnable(GL_LIGHTING);

	/* this is a positioned light */
	glEnable(GL_LIGHT0);

	/* this is a directed light */
	glEnable(GL_LIGHT1);

	/* this is a spotlight (not initiated til later) */
	glEnable(GL_LIGHT2);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* set the ambient light */
	GLfloat ambientColor[] = { 0.2, 0.2, 0.2, 1.0 };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	GLfloat lightColor0[] = { 0.5, 0.5, 0.5, 1.0 };
	GLfloat lightPos0[] = { 0.0f, 1.5f, -1.0f, 0.0f };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	GLfloat lightColor1[] = { 0.8f, 0.8f, 0.8f, 1.0f };
	GLfloat lightPos1[] = { 1.0f, 2.0f, -2.0f, 0.0f };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
	glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);

	/* draw the table */
	glPushMatrix();
	glTranslatef(-0.3, 0, -1.25);
	glRotatef(180, 0, 1.0, 1.0);

	/*~~~~~~~~~~~~~~~~~~~~~~~*/
	float	cylbase = 0.60;
	float	cyltop = 0.15;
	float	cylheight = 1.0;
	float	tableheight = 0.10;
	float	tablecirc = 0.90;
	/*~~~~~~~~~~~~~~~~~~~~~~~*/

	setMaterial(finTable);
	setColor(TABLE2);
	gluCylinder(quadratic, cylbase, cyltop, cylheight, splines * LOD, splines * LOD);
	glTranslatef(0, 0, cylheight);
	gluDisk(quadratic, 0.0, cyltop, splines * LOD, splines * LOD);
	gluCylinder(quadratic, tablecirc, tablecirc, tableheight, splines * LOD, splines * LOD);
	gluDisk(quadratic, 0.0, tablecirc, splines * LOD, splines * LOD);
	glTranslatef(0, 0, tableheight);
	gluDisk(quadratic, 0.0, tablecirc, splines * LOD, splines * LOD);
	setMaterial(finDefault);
	glPopMatrix();
	glPushMatrix();

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* initiate the spotlight */
	GLfloat light_ambient2[] = { 0.0, 0.0, 0.0, 1.0 };
	GLfloat light_diffuse2[] = { 0.0, 0.3, 0, 1.0 };
	GLfloat light_specular2[] = { 0.0, 0.3, 0, 1.0 };
	GLfloat lightPos2[] = { 0.0f, 3.0f, 0.0f, 0.0f };
	GLfloat spot_direction[] = { 0, -1.0, 0 };
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	glLightfv(GL_LIGHT2, GL_AMBIENT, light_ambient2);
	glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse2);
	glLightfv(GL_LIGHT2, GL_SPECULAR, light_specular2);
	glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 30.0);
	glLightfv(GL_LIGHT2, GL_POSITION, lightPos2);
	glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot_direction);

	/* draw the chairs and rotate them around the table */
	glRotatef(270, 0.0, 1.0, 0.0);
	glTranslatef(-1.5, 0, 1.5);
	glPushMatrix();
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.3, 0, -1.25);
	glRotatef(90, 0, 1.0, 0.0);
	glTranslatef(-0.3, 0, 1.25);
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.3, 0, -1.25);
	glRotatef(180, 0, 1.0, 0.0);
	glTranslatef(-0.3, 0, 1.25);
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0.3, 0, -1.25);
	glRotatef(270, 0, 1.0, 0.0);
	glTranslatef(-0.3, 0, 1.25);
	glRotatef(90, 0, 1.0, 0.0);
	chair();
	glPopMatrix();

	/* draw the cups/forks and rotate around the table */
	glPushMatrix();
	glTranslatef(0.35, 1.1, -0.25);
	cups();
	glPushMatrix();
	glTranslatef(-0.05, 0, -1.0);
	glRotatef(90, 0, 1.0, 0);
	glTranslatef(0.05, 0, 1.0);
	cups();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(-0.05, 0, -1.0);
	glRotatef(180, 0, 1.0, 0);
	glTranslatef(0.05, 0, 1.0);
	cups();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(-0.05, 0, -1.0);
	glRotatef(270, 0, 1.0, 0);
	glTranslatef(0.05, 0, 1.0);
	cups();
	glPopMatrix();
	glPopMatrix();

	/* draw the teapot */
	glPushMatrix();

	/* put on table */
	glTranslatef(0.3, 1.3, -1.25);

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* trans values for animation */
	static int		rotateval = 1;
	static int		rotatevalx = 0;
	static float	transvaly = 0;
	static float	transvalx = 0;
	/* clock values for animation */
	static int		beginslow = 0;
	static int		slowclock = 0;
	static int		pourclock = 0;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	/* only animate when playing */
	if(ani_play)
	{
		{
			/*~~~*/
			int ii;
			/*~~~*/

			for(ii = 0; ii < speed; ii++)
			{
				{

					/* section where teapot slows */
					if((beginslow))
					{
						{
							if(((20 - slowclock / 10) > 0))
							{
								rotateval = rotateval + (20 - slowclock / 10);
								slowclock++;
							}
							else
							{
								{

									/* section where teapot is pouring */
									if(pourclock < 90)
									{
										{
											rotatevalx = pourclock / 2;
											transvaly = ((double) pourclock) / (double) 200;
											transvalx = ((double) pourclock) / (double) 400;
										}
									}
									else if(pourclock < 135)
									{	/* teapot in mid air */
										rotatevalx = 45;
										transvaly = 90.0 / 200;
										transvalx = 90.0 / 400;
									}
									else if(pourclock < 225)
									{
										{	/* teapot is being set down */
											rotatevalx = 45 - (pourclock - 135) / 2;
											transvaly = 90.0 / 200 - ((double) pourclock - 135) / (double) 200;
											transvalx = 90.0 / 400 - ((double) pourclock - 135) / (double) 400;
										}
									}
									else if(pourclock < 300)
									{		/* teapot is back on table */
										rotatevalx = 0;
										transvaly = 0;
										transvalx = 0;
									}
									else
									{
										{	/* reset variables for next play */
											ani_play = 0;
											ani_clock = 0;
											rotateval = 1;
											ani_direction = 0;
											slowclock = 0;
											pourclock = -speed;
											beginslow = 0;
											rotatevalx = 0;
											transvaly = 0;
											transvalx = 0;
										}
									}

									pourclock++;
								}
							}
						}
					}
					else if(ani_clock < 200)
					{			/* teapot is speeding up it's spin */
						rotateval = rotateval + ani_clock / 10;
					}
					else if(ani_clock < 500)
					{
						{		/* teapot is at constant spin */
							rotateval = rotateval + 20;
							if(ani_clock == 300)
							{	/* choose the cup it will stop at */
								ani_direction = rand() % 4 + 1;
							}
						}
					}

					if(rotateval > 360) rotateval -= 360;
					if
					(
						(!beginslow)
					&&	(ani_direction != 0)
					&&	(
							(
								(rotateval >= ani_direction * 90 - SLOWMAGIC - 20)
							&&	(rotateval <= ani_direction * 90 - SLOWMAGIC)
							)
						||	(
									(rotateval >= ani_direction * 90 - SLOWMAGIC + 340)
								&&	(rotateval <= ani_direction * 90 - SLOWMAGIC + 360)
								)
						)
					)
					{			/* choose opportune moment to slow down */
						beginslow = 1;
						rotateval = ani_direction * 90 - SLOWMAGIC + 360;
						if(rotateval > 360) rotateval -= 360;
					}

					ani_clock++;
				}
			}
		}	/* apply transformations */
	}

	glRotatef(rotateval, 0, 1.0, 0);
	glTranslatef(transvalx, transvaly, 0);
	glRotatef(-rotatevalx, 0, 0, 1.0);

	/* apply texture */
	glBindTexture(GL_TEXTURE_2D, texture[1]);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glEnable(GL_TEXTURE_2D);

	/* apply finish */
	setMaterial(finPot);
	glutSolidTeapot(0.2);
	setMaterial(finDefault);
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
	glPopMatrix();
	glPopMatrix();

	/* 3D stuff is done */
	glFlush();

	/* draw text overlay */
	glDisable(GL_NORMALIZE);
	glDisable(GL_LIGHTING);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();

	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	char	speedstring[20];
	char	str[500] = "<Z> and <z>: zoom in/out\n<X> or <x>: Start/Stop X rotation\n<Y> or <y> Start/Stop Y Rotation\n<A> or <a>: Start animation\n<F> or <f>: Speed up animation\n<S> or <s>: Slow down animation\n<T> or <t>: Pause animation\n<C> or <c>: Resume the animation\n<p>: switch the rendering to the flat shaded polygonization.\n<P> switch the rendering to the smooth shaded polygonization.\n<q> or <Q>: change fog mode\nspeed: ";
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

	sprintf(speedstring, "%d", speed);
	strcat(str, speedstring);
	strcat(str, "\nLOD: ");
	sprintf(speedstring, "%d", LOD);
	strcat(str, speedstring);
	strcat(str, "\nFog Mode: ");
	switch(fogfilter)
	{
		{
		case 0: strcat(str, "GL_EXP"); break;
		case 1: strcat(str, "GL_EXP2"); break;
		case 2: strcat(str, "GL_LINEAR"); break;
		case 3: strcat(str, "NO FOG"); break;
		}
	}

	bitmap_output(30, 30, str, GLUT_BITMAP_HELVETICA_12);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();

	/* draw transparent box for text */
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT), 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f((float) 0, (float) 0, (float) 0, (float) 0.6);
	glRecti(30 - 10, 30 - 20, 40 + 350, 30 + 250);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glFlush();
	glutSwapBuffers();
}