#include <windows.h>
#include <GL/glut.h>
#include <gl/glu.h>
#include <math.h>
#ifndef M_PI
define M_PI (double)3.14159265358979323846
#endif /* !M_PI */
#include “texture.h”
/*
int Width; /* Width of window /
int Height; / Height of window /
GLuint F16Body, / F-16 body /
F16Rolleron[2]; / F-16 rollerons /
GLuint F16Texture[2]; / Camoflage texture objects /
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 UseTexturing = 1; / Use texture mapping? /
GLfloat Orientation[3] = / Orientation of viewer */
{
15.0, 45.0, 30.0
};
/*
void BuildF16(void);
void APIENTRY glu_vertex(GLdouble *xyz);
double GetClock(void);
void Idle(void);
void Keyboard(unsigned char key, int x, int y);
//void Joystick(unsigned state, int x, int y, int z);
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);
/*
- ‘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);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(792, 573);
glutCreateWindow(“F-16 Using Quadrics and GLU Polygons”);
glutDisplayFunc(Redraw);
glutKeyboardFunc(Keyboard);
glutMouseFunc(Mouse);
glutMotionFunc(Motion);
glutReshapeFunc(Resize);
//if (glutDeviceGet(GLUT_HAS_JOYSTICK))
// glutJoystickFunc(Joystick, 100);
BuildF16();
glutMainLoop();
return (0);
}
/*
- ‘BuildF16()’ - Build the F-16 model.
*/
void
BuildF16(void)
{
int i; /* Looping var */
GLUquadricObj *gluNewQuadric(void);//GLUquadric quadric; / Quadric object */
#ifdef GLU_VERSION_1_2
GLUtesselator tess; / Tesselator object */
#else
GLUtriangulatorObj tess;
#endif / GLU_VERSION_1_2 /
static GLdouble wing[][5] = / Main wing points /
{
/ { x, y, z, s, t } /
{ 0.25, 0.0, -1.0, 0.125, 0.0 },
{ 0.45, 0.0, 0.0, 0.25, 0.4 },
{ 1.65, 0.0, 0.8, 1.0, 0.8 },
{ 1.65, 0.0, 1.2, 1.0, 1.0 },
{ 0.35, 0.0, 1.2, 0.15, 1.0 },
{ 0.35, 0.0, 2.4, 0.15, 2.0 },
{ 0.25, 0.0, 2.4, 0.125, 2.0 },
{ 0.25, 0.0, 2.0, 0.125, 1.5 },
{ -0.25, 0.0, 2.0, -0.125, 1.5 },
{ -0.25, 0.0, 2.4, -0.125, 2.0 },
{ -0.35, 0.0, 2.4, -0.15, 2.0 },
{ -0.35, 0.0, 1.2, -0.15, 1.0 },
{ -1.65, 0.0, 1.2, -1.0, 1.0 },
{ -1.65, 0.0, 0.8, -1.0, 0.8 },
{ -0.45, 0.0, 0.0, -0.25, 0.4 },
{ -0.25, 0.0, -1.0, -0.125, 0.0 }
};
static GLdouble tail[][5] = / Tail points /
{
/ { x, y, z, s, t } /
{ 0.0, 0.24, 0.5, 1.5, 0.0 },
{ 0.0, 0.4, 1.1, 1.2, 0.1 },
{ 0.0, 1.0, 2.0, 0.4, 1.0 },
{ 0.0, 1.0, 2.4, 0.05, 1.0 },
{ 0.0, 0.4, 2.1, 0.2, 0.1 },
{ 0.0, 0.24, 2.1, 0.2, 0.0 }
};
static GLdouble left_fin[][5] = / Left fin points /
{
/ { x, y, z, s, t } /
{ -0.1, -0.1, 1.1, 0.0, 0.0 },
{ -0.25, -0.3, 1.2, 1.0, 0.0 },
{ -0.25, -0.3, 1.5, 1.0, 1.0 },
{ -0.1, -0.1, 1.5, 1.0, 0.0 }
};
static GLdouble right_fin[][5] = / Right fin points /
{
/ { x, y, z, s, t } /
{ 0.1, -0.1, 1.1, 0.0, 0.0 },
{ 0.25, -0.3, 1.2, 1.0, 0.0 },
{ 0.25, -0.3, 1.5, 1.0, 1.0 },
{ 0.1, -0.1, 1.5, 1.0, 0.0 }
};
static GLdouble left_rolleron[][5] = / Left rolleron points /
{
/ { x, y, z, s, t } /
{ -0.35, 0.0, 1.6, 0.0, 0.0 },
{ -0.85, 0.0, 2.1, 1.0, 0.5 },
{ -0.85, 0.0, 2.4, 1.0, 1.0 },
{ -0.35, 0.0, 2.4, 0.0, 1.0 }
};
static GLdouble right_rolleron[][5] = / Right rolleron points /
{
/ { x, y, z, s, t } */
{ 0.35, 0.0, 1.6, 0.0, 0.0 },
{ 0.85, 0.0, 2.1, 1.0, 0.5 },
{ 0.85, 0.0, 2.4, 1.0, 1.0 },
{ 0.35, 0.0, 2.4, 0.0, 1.0 }
};
/* Load the texture images */
F16Texture[0] = TextureLoad("camoflage.bmp", GL_FALSE, GL_NEAREST,
GL_NEAREST, GL_REPEAT);
//changed the tail.bmp to flag.bmp
F16Texture[1] = TextureLoad("flag.bmp", GL_FALSE, GL_NEAREST,
GL_NEAREST, GL_REPEAT);
/* Then build the F-16 body */
F16Body = glGenLists(1);
glNewList(F16Body, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, F16Texture[0]);
//This section is wierd. Check the flow for the declarations for the callback
//starting at the top and working down to here. The first gluTesscallBack is what the
//book says it should look like. The other two are what they did look like.
tess = gluNewTess();
void gluTessCallback(GLUtesselator *tess, GLenum GLU_TESS_BEGIN, glBegin);
void gluTessCallback(tess, GLU_TESS_END, glEnd);
void gluTessCallback(tess, GLU_TESS_VERTEX);
void (CALLBACK *)()glu_vertex);
//Need to work on how to structure this section properly
//GLUquadricObj *quadric;
quadric = gluNewQuadric();
void gluQuadricTexture(GLUquadricObj *quadric, GLboolean GL_TRUE);
and the resultant errors being generated are:
Info :Compiling C:\documents and settings\mark jeffcoat\school program files\project files\f16mod.cpp
Error: f16mod.cpp(173,37):Undefined symbol ‘GLUtesselator’
Error: f16mod.cpp(174,29):Undefined symbol ‘tess’
Error: f16mod.cpp(175,29):Undefined symbol ‘tess’
Error: f16mod.cpp(176,20):Expression syntax
Error: f16mod.cpp(180,12):Undefined symbol ‘quadric’
Error: f16mod.cpp(181,67):Undefined symbol ‘GLUquadricObj’
Error: f16mod.cpp(200,23):Call to undefined function ‘gluTessBeginPolygon’
Error: f16mod.cpp(211,21):Call to undefined function ‘gluTessEndPolygon’
Warn : f16mod.cpp(431,4):‘j’ is declared but never used
Warn : f16mod.cpp(431,4):‘i’ is declared but never used
Error: f16mod.cpp(446,5) eclaration terminated incorrectly
Error: f16mod.cpp(450,15):Type name expected
Error: f16mod.cpp(450,15):Multiple declaration for ‘MouseStartY’
Error: f16mod.cpp(27,15):Earlier declaration of ‘MouseStartY’
Error: f16mod.cpp(450,26):Undefined symbol ‘y’
Error: f16mod.cpp(452,4) eclaration terminated incorrectly
Error: f16mod.cpp(467,7) eclaration terminated incorrectly