#include <windows.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <stdio.h>
#include <zlib.h>
#include <math.h>
#include “texture.h”
#ifndef WIN32
include <sys/time.h>
#endif /* !WIN32 */
#ifndef M_PI
define M_PI (double)3.14159265358979323846
#endif /* !M_PI */
/*
- Constants:
*/
#ifndef APIENTRY
define APIENTRY
#endif /* !APIENTRY */
#define TERRAIN_COUNT 121 /* Number of postings (must be odd) /
#define TERRAIN_SIZE 12000.0 / Size of terrain database /
#define TERRAIN_VIEW 2000.0 / Viewable distance in terrain database /
#define TERRAIN_SPACING 100.0 / Spacing between postings */
/*
- Terrain cell bits:
- XX 01 XX
- 02 04 08
- XX 10 XX
- XX = always drawn.
*/
#define TC_TOP 0x01
#define TC_LEFT 0x02
#define TC_CENTER 0x04
#define TC_RIGHT 0x08
#define TC_BOTTOM 0x10
#define TC_VERT (TC_TOP | TC_CENTER | TC_BOTTOM)
/*
- Terrain posting structure…
*/
typedef struct
{
GLfloat v[3]; /* Position /
GLfloat n[3]; / Lighting normal /
int used; / Is this posting used? */
} TP;
/*
- Globals…
*/
int Width; /* Width of window /
int Height; / Height of window /
double LastTime; / Last update time /
int MouseStartX; / Initial mouse X position /
int MouseStartY; / Initial mouse Y position /
int MouseX; / Mouse X position /
int MouseY; / Mouse Y position /
int ViewAngle = 0; / Viewing angle /
GLenum PolyMode = GL_FILL;/ Polygon drawing mode /
int UseTexturing = 1; / Use texturing? /
int ShowAircraft = 1; / Show the F-16? /
int ShowFog = 1; / Show fog? /
int ShowLighting = 1; / Show lighting? /
int ShowSky = 1; / Show sky? /
int ShowTerrain = 1; / Show 3D terrain? /
int ShowWater = 1; / Show water? /
GLfloat WaterLevel = 0.0; / Level of water /
GLfloat Velocity = 50.0; / Flying speed /
GLfloat Position[3] = / Position of viewer /
{
0.0, 10.0, 0.0
};
GLfloat Orientation[3] = / Orientation of viewer /
{
0.0, 0.0, 0.0
};
GLfloat OrientRate[3] = / Orientation rates of aircraft /
{
0.0, 0.0, 0.0
};
GLuint F16Body, / F-16 body /
F16Rolleron[2]; / F-16 rollerons /
GLuint F16Texture[2]; / Camoflage texture objects /
int TerrainCount; / Number of columns of terrain /
TP Terrain[TERRAIN_COUNT][TERRAIN_COUNT];
/ Terrain postings /
GLuint TerrainList; / Terrain display list /
GLuint LandTexture; / Land texture object /
GLuint SkyTexture; / Sky texture object */
/*
- Functions…
*/
void BuildF16(void);
void APIENTRY glu_vertex(GLdouble *xyz);
double GetClock(void);
void Idle(void);
//void Joystick(unsigned state, int x, int y, int z);
void Keyboard(unsigned char key, int x, int y);
void LoadTerrain(int lat, int lon);
void Motion(int x, int y);
void Mouse(int button, int state, int x, int y);
void Redraw(void);
void Resize(int width, int height);
void Special(int key, int x, int y);
/*
- ‘main()’ - Open a window and display a sphere and cube.
*/
int /* O - Exit status /
main(int argc, / I - Number of command-line arguments */
char argv[]) / I - Command-line arguments /
{
glutInit(&argc, argv);
#ifdef BOOK_COVER
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
#else
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
#endif / BOOK_COVER */
glutInitWindowSize(792, 573);
glutCreateWindow(“Tesselated Terrain”);
glutDisplayFunc(Redraw);
// if (glutDeviceGet(GLUT_HAS_JOYSTICK))
// glutJoystickFunc(Joystick, 200);
glutKeyboardFunc(Keyboard);
glutMotionFunc(Motion);
glutMouseFunc(Mouse);
glutReshapeFunc(Resize);
glutSpecialFunc(Special);
BuildF16();
LandTexture = TextureLoad("land.bmp", GL_FALSE, GL_LINEAR_MIPMAP_LINEAR,
GL_LINEAR, GL_REPEAT);
SkyTexture = TextureLoad("sky.bmp", GL_FALSE, GL_LINEAR, GL_LINEAR,
GL_CLAMP);
LoadTerrain(36, -112);
puts("QUICK HELP:");
puts("");
puts("ESC - Quit");
puts("',' - Slow down, '<' - Slowest");
puts("'.' - Speed up, '>' - Fastest");
puts("'3' - Toggle terrain");
puts("'a' - Toggle aircraft");
puts("'f' - Toggle fog");
puts("'l' - Toggle lighting");
puts("'s' - Toggle sky/clouds");
puts("'t' - Toggle texturing");
puts("'w' - Toggle water");
puts("'W' - Toggle wireframe");
glutMainLoop();
return (0);
}
/*
- ‘BuildF16()’ - Build the F-16 model.
*/
void
BuildF16(void)
{
int i; /* Looping var */
GLUquadric quadric; / Quadric object */
#ifdef GLU_VERSION_1_2
GLUtesselator tess; / Tesselator object */
#else
GLUtriangulatorObj tess;
#endif / GLU_VERSION_1_2 */
This code is generating undefined symbol errors for GLUquadric, quadric and GLU_TESS_BEGIN.
Can’t find the error. Can anyone see the problem?