GLUquadric use

Ran into a problem trying to compile some existing code that I am modifying as part of a practice run for my openGL class and for the life of me cannot figure why this is happening. Here is the snip of code: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 /
static GLdouble wing[][5] = /
Main wing points */
{

Upon compile I get “undefined symbols” for GLUquadric and *quadric. Any ideas why?? Just a newbie lost as usual…

Undefined symbols tends to be an error given by the linker, so I’m guessing maybe you just haven’t included opengl32.lib and glu32.lib into your linker settings. How you do that depends a lot on your compiler. For vc++ it’s Project->Settings->Link->Object/Modules (or something like that)

If it’s NOT a linker error and is a compile error, try posting a bit more code. (If you’re not sure what the difference between a compile and linker error is, post the whole error. you can usually tell from that if it was generated by the compiler or the linker.)

#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”

/*

  • Globals…
    */

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
};

/*

  • Functions…
    */

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

Still ned help with this one if anyone has any input would be greatful.

Ok, I haven’t worked with Tesselators before, but I can see some weird things just with the structure of some of the code. First of all, what do you use for a compiler?

Error: f16mod.cpp(173,37):Undefined symbol ‘GLUtesselator’
Error: f16mod.cpp(174,29):Undefined symbol ‘tess’

To start with, the above sounds like you possibly have an old version of glu.h

GLUquadricObj *gluNewQuadric(void);//GLUquadric quadric; / Quadric object */

This appears to be a redefinition of the gluNewQuadric function. Not only that, but it’s a redefinition of a function within another function. Since you don’t seem to be using any GLUquadricObjs until down at the bottom of the code, my guess is you can just remove this line.

tess = gluNewTess();
void gluTessCallback(GLUtesselator *tess, GLenum GLU_TESS_BEGIN, glBegin);
void gluTessCallback(tess, GLU_TESS_END, glEnd);
void gluTessCallback(tess, GLU_TESS_VERTEX);

Ok… the 3 gluTessCallback function calls there are odd.

  1. You shouldn’t have the void in front of them.
  2. For the GLU_TESS_BEGIN one you shouldn’t be adding the parameter types in the function call.
  3. glBegin doesn’t have the function definition gluTessCallback expects. Here’s where I’m not sure what to do since I haven’t worked with tesselators. My instinct is to create your own function, from which you call glBegin.
  4. You don’t specify a callback function for the third gluTessCallback.

To sum up… here’s more or less how those should look.
gluTessCallback(tess, GLU_TESS_BEGIN, glMyBegin);
gluTessCallback(tess, GLU_TESS_END, glEnd);
gluTessCallback(tess, GLU_TESS_VERTEX, MyVeryOwnTessVertexFunction);

void (CALLBACK *)()glu_vertex);

I’m not quite sure what this is. Unless maybe that was meant to be used as the 3rd parameter of your last gluTessCallback? If that’s the case that line should look like
gluTessCallback(tess, GLU_TESS_VERTEX, glu_vertex); and you need to create the glu_vertex function.

//GLUquadricObj *quadric;
quadric = gluNewQuadric();

You’ll need to uncomment that first line so that quadric is declared.

void gluQuadricTexture(GLUquadricObj *quadric, GLboolean GL_TRUE);

Again, this is looking like a cross between a function declaration, and actually trying to use the gluQuadricTexture function. I’m assuming you want the latter in this case. Change it to look like so

gluQuadricTexture(quadric, GL_TRUE);

With these changes I can get it to compile (after adding in some other functions you didn’t supply), but w/o code for the vertex tesselator callback, it really doesn’t do anything. Hope that helps give you a start, at least.