/* NURB curve (1-dimension) Testing whether we really get a quarter circle with the NURBS given in Rogers and also in Hill, and whether the curve goes outside the convex hull. Written by Caroline Geiersbach and Scott D. Anderson scott.anderson@acm.org Summer 2003 */ #include #include #include #include const int order=3; const int numPoints = 3; GLfloat W = sqrt(2)/2; GLfloat knots[6] = {0,0,0,1,1,1}; GLfloat points[numPoints][4] = { {1,0,0,1}, {W,W,0,W}, {0,1,0,1}}; void curve2() { GLUnurbs* NURBS2=gluNewNurbsRenderer(); gluNurbsProperty(NURBS2,GLU_DISPLAY_MODE,GLU_FILL); glColor3f(1,0,0); // red gluBeginCurve(NURBS2); gluNurbsCurve(NURBS2,numPoints+order,knots,4,&points[0][0],order, GL_MAP1_VERTEX_4); gluEndCurve(NURBS2); gluDeleteNurbsRenderer(NURBS2); } void display(void) { glClearColor(0.7,0.7,0.7,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // since the figure is in the unit square, this should work. float margin = 0.2; glOrtho(0-margin,1+margin, 0-margin,1+margin, 0,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); points[1][0] = points[1][1] = points[1][3] = W; glLineWidth(3); glColor3f(0,1,0); glBegin(GL_LINE_STRIP); for(int i=0; i1) { printf("enabling map1 vertex4\n"); glEnable(GL_MAP1_VERTEX_4); } glutMainLoop(); return 0; }