c++ - gluDisk() function opengl -
i trying create function in program draws disk. have .h file called drawshape have drawing functions there. trying add drawdisk it, seen below;howerver keep getting error saying have undefined reference glunewquadric , gludisk. have #included glu.h library, i'm not sure wrong code.
void drawdisk(double indiameter, double outdiameter, int vertslices, int horizslices) { gluquadricobj *disk; disk = glunewquadric(); gludisk(disk, indiameter, outdiameter, vertslices, horizslices); }
here makefile requested below in 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 system environment , 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 ######################################################################## ######################################################################## = $(exedir)/solarsystem .phony: 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
i figured out. wrote function lets me draw disk , add texture 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 = 2; < 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(); } }
Comments
Post a Comment