NURBS and B-splines

Posted on 2003-11-07
Last Modified: 2007-12-19
I am trying to create an interactive NUBRS (with openGL) in C where user is available to select the points with the click of the mouse. However, as soon as I made 25 points the nurb dissapier from the screen .. does anyone have any idea why would be doing something like that.

Here is the part of my code that does it

void render_bspline(void)
      GLUnurbsObj *theNurb;
        GLfloat      knots[MAX_POINTS*2];
      int i=0;
                  knots[i] =0.0;
  theNurb = gluNewNurbsRenderer();
  gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0);
        glColor3f(1.0,0.0, 0.0 );
                  gluNurbsCurve(theNurb, numpoints*2, knots,3,&ctlpoints[0][0], numpoints,GL_MAP1_TEXTURE_COORD_2);
                  gluNurbsCurve(theNurb, numpoints*2, knots,3,&ctlpoints[0][0], numpoints,GL_MAP1_NORMAL);
                    gluNurbsCurve(theNurb, numpoints*2, knots,3,&ctlpoints[0][0], numpoints,GL_MAP1_VERTEX_3);

Thanks for taking your time to look at this
Question by:ledeni
  • 4
  • 2
  • 2
LVL 45

Expert Comment

by:Kent Olsen
ID: 9712056

What's the value of MAX_POINTS?


Author Comment

ID: 9712150
hey Kent .. thanks for looking at it ... MAX_POINTS is 255 .. that I am also using as a array max points for that control points ... so my array is initializes as
cntrlpoints[MAX_POINTS][3] and that array gets populated with the values that I select with the mouse on the open window. And since my understanding that knots are 2 times number of control points that is why I initiate the knots as MAX_POINTS * 2

Thanks a bunch once more


Author Comment

ID: 9712161
And one more thing ... and that is that the numpoints is the current selected number of points on the screen
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

LVL 45

Accepted Solution

Kent Olsen earned 100 total points
ID: 9714538

What is the value of numpoints when you enter the function?

Also, as a matter of technique, if you're passing the array ctlpoints to a function you can use the name instead of taking the address of the first element.

              gluNurbsCurve(theNurb, numpoints*2, knots, 3, &ctlpoints[0][0], numpoints, GL_MAP1_TEXTURE_COORD_2);


              gluNurbsCurve(theNurb, numpoints*2, knots, 3, ctlpoints, numpoints, GL_MAP1_TEXTURE_COORD_2);


Author Comment

ID: 9715317
Hey Kent

numpoints is 2 when I enter the function ... b.c. at least I think I should not be drawing the b-spline before I have at least 2 points. However I think that my problem is my understanding the entire process of knots, nurbs, etc etc ...

Maybe you can be more of assistance to me if you can just point me in direction of how many knots I should be having at some point for e.g. if I have chosen 2 points on the screen .. then should there be a 4 knots to it ... and should my order by number of points selected. all in all how gluNurbCurve works for dynamicly populated array of elements.

Thanks again for looking at this ... and I will just bump up some more points on this question now ... thanks again

Author Comment

ID: 9723364
Hey Kent .. just thought to let you know (or anyone else) that I have figured out the nerb drawing ... I was wondering if anyone would know what type of openGL command lines I can use to spin this 2D nurb around the Z axis to get the 3D image.

Thanks ... a bunch once more for looking at this ..

LVL 45

Assisted Solution

sunnycoder earned 100 total points
ID: 9729849
LVL 45

Expert Comment

ID: 9729871
you may also like to read this --- it des not have nerbs but rotation -- yes

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Estimate porting issues. 9 120
Test against App 49 138
How to design, and implement simple interface 5 137
How do I set up two external hard drives with Acronis True Image? 12 92
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question