#include #include #include /* * nonuniform rational B-spline circle * * 4/7/03 pjf * */ #define NP 9 #define NKNOTS 12 #define ORDER 3 #define STRIDE 4 GLfloat p[9][4] = {{ 0.5,0,0,1 }, {0.5,0.5,0,.707}, {0,0.5,0,1}, {-0.5,0.5,0,.707}, {-0.5,0,0,1}, {-0.5, -0.5, 0,.707}, {0, -0.5, 0,1}, {0.5, -0.5, 0,.707}, {0.5,0,0,1}}; GLfloat knots[12] = { 0,0,0,1,1,2,2,3,3,4,4,4 }; GLUnurbsObj *nurb; int ww,hh; void CALLBACK nurbsError(GLenum errorCode) { const GLubyte *s = gluErrorString(errorCode); fprintf(stderr,"NURBS error: %s\n",s); exit(-1); } /* display callback */ void display() { int i; glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,1.0,1.0); gluBeginCurve(nurb); gluNurbsCurve(nurb,NKNOTS,knots, STRIDE,&p[0][0],ORDER,GL_MAP1_VERTEX_4); gluEndCurve(nurb); // now draw boxes around control points for (i=0;i