3

我正在尝试在我的程序中创建一个绘制磁盘的函数。我有一个名为 drawShape 的 .h 文件,其中有我所有的绘图功能。我正在尝试向其中添加 drawDisk,如下所示;但是我不断收到错误消息,说我对 gluNewQuadric 和 gluDisk 有未定义的引用。我已经#included glu.h 库,所以我不确定我的代码有什么问题。

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

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

这是我在评论部分中要求的makefile。

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 
4

1 回答 1

0

我想到了。我编写了这个函数,让我可以绘制磁盘并为其添加纹理。

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

}
于 2013-07-01T15:40:07.907 回答