include GL glut GLUnurbsObj nobj GLfloat ctlarray -0 -0 -0 -0 void ini

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <GL/glut.h>
GLUnurbsObj* nobj;
GLfloat ctlarray [] [3] = {{-0.9,-0.8,0.0},
{-0.2,0.8,0.0},
{0.2,-0.5,0.0},
{0.9,0.8,0.0}};
void init (void)
{
glClearColor (1,1,1,1);
nobj = gluNewNurbsRenderer();
gluNurbsProperty (nobj, GLU_SAMPLING_TOLERANCE,25.0);
}
void Display ()
{
GLfloat knot[]={0.0,0.0,0.0,1.0,2.0,2.0,2.0};
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth (3.0);
glColor3f (0,0.3,1);
gluNurbsCurve (nobj,7,knot,3,&ctlarray [0][0],3,GL_MAP1_VERTEX_3);
glPointSize (4.0);
glColor3f (0.0,0.0,1);
glBegin (GL_POINTS);
for (int i = 0; i<4;i++)
{
glVertex3f (ctlarray[i][0],ctlarray[i][1],ctlarray[i][2]);
}
glEnd ();
glFinish ();
}
void main ()
{
glutInitDisplayMode (GLUT_RGBA | GLUT_SINGLE);
glutInitWindowSize (480,480);
glutInitWindowPosition (100,100);
glutCreateWindow (" ");
init ();
glutDisplayFunc (Display);
glutMainLoop ();
}