Question

I am trying to create a function in my program that draws disk. I have a .h file called drawShape where I have all my drawing functions there. I am trying to add drawDisk to it, as seen below;howerver I keep getting an error saying that I have an undefined reference to gluNewQuadric and gluDisk. I have #included the glu.h library, so I'm not sure what is wrong with my code.

void drawDisk(double inDiameter, double outDiameter, int vertSlices, int horizSlices)
{
    GLUquadricObj *disk;
    disk = gluNewQuadric();

    gluDisk(disk, inDiameter, outDiameter, vertSlices, horizSlices);
}

Here is my makefile as requested below in the comments section.

VRUI_MAKEDIR := /opt/local/Vrui-2.6/share/make
ifdef DEBUG
  VRUI_MAKEDIR := $(VRUI_MAKEDIR)/debug
endif

INSTALLDIR := $(shell pwd)

# Set resource directory:
RESOURCEDIR = images

########################################################################
########################################################################

# Include definitions for the system environment and system-provided
# packages
include $(VRUI_MAKEDIR)/SystemDefinitions
include $(VRUI_MAKEDIR)/Packages.System
include $(VRUI_MAKEDIR)/Configuration.Vrui
include $(VRUI_MAKEDIR)/Packages.Vrui

# Set installation directory structure:
BININSTALLDIR = $(INSTALLDIR)/$(EXEDIR)
RESOURCEINSTALLDIR = $(INSTALLDIR)/$(RESOURCEDIR)

########################################################################
########################################################################

PACKAGES = MYVRUI

########################################################################
########################################################################

ALL = $(EXEDIR)/SolarSystem     

.PHONY: all
all: $(ALL)

########################################################################
#'make clean'
########################################################################

.PHONY: extraclean
extraclean:

.PHONY: extrasqueakyclean
extrasqueakyclean:

# Include basic makefile
include $(VRUI_MAKEDIR)/BasicMakefile

########################################################################
########################################################################
TEST = drawShape.cpp\
    solarSystem.cpp\
    planet.cpp\
    skybox.cpp

$(OBJDIR)/SolarSystem.o: CFLAGS += -DPICDIR='"$(RESOURCEINSTALLDIR)"'

$(EXEDIR)/SolarSystem: $(TEST:%.cpp=$(OBJDIR)/%.o)


    install: $(ALL)
    @echo Installing Vrui example programs in $(INSTALLDIR)...
    @install -d $(BININSTALLDIR)
    @install $(ALL) $(BININSTALLDIR)
    @install -d $(RESOURCEINSTALLDIR)
    @install $(RESOURCEDIR)/EarthTopography.png 
Was it helpful?

Solution

I figured it out. I wrote this function that lets me draw the disk and add texture to it.

void drawDisk(double radiusX, double eccentricity, int inRadius, int sideSmooth)
{   
double radiusY = 0.01;
double pi = Math::Constants<double>::pi;
double texY1 = 1.0f/double(inRadius);
double lat1 = 1.0f*pi/double(inRadius)-0.5f*pi;
double r1 = cosf(lat1);
double z1 = sinf(lat1);
for(int i = 2; i < inRadius; ++i)
{
    double r0 = r1;
    double z0 = z1;
    double texY0 = texY1;
    texY1 = double(i)/double(inRadius);
    lat1 = double(i)*pi/double(inRadius)-0.5f*pi;
    r1 = cosf(lat1);
    z1 = sinf(lat1);

    glBegin(GL_QUAD_STRIP);
    for(int j=0; j <= sideSmooth; ++j)
    {
        double texX = double(j)/double(sideSmooth);
        double lng = double(j)*(2.0f*pi)/double(sideSmooth);
        double x1 = cosf(lng) * r1;
        double y1 = sinf(lng) * r1;
        glNormal3f(x1,y1,z1);
        glTexCoord2f(texX,texY1);
        glVertex3f(x1*radiusX,y1*radiusX*eccentricity,z1*radiusX*radiusY);
        double x0 = cosf(lng)*r0;
        double y0 = sinf(lng)*r0;
        glNormal3f(x0,y0,z0);
        glTexCoord2f(texX,texY0);
        glVertex3f(x0*radiusX,y0*radiusX*eccentricity,z0*radiusX*radiusY);
    }
    glEnd();
}

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top