Hello,

I am OpenGL beginner and I try to create a Nurbssurface. I have some troubles to understand the idea behind Nurbs.

I've already created a surface grid with random height Values.
I tried two ways:

1)
Code :
glBegin(TRIANFLE_STRIP)
glVertex(x,y,z);
glVertex(x+1,y,z);
glVertex(x,y+1,z);
glVertex(x+1,y+1,z);
glEnd();

2) VertexShader
Just a clipping
Code :
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, VBO[0]);
                glBufferData(OpenGL.GL_ARRAY_BUFFER,arrayOfVertices,OpenGL.GL_STATIC_DRAW);
                glEnableVertexAttribArray(0);
                glVertexAttribPointer(0, width * height * 3, OpenGL.GL_FLOAT, false, 3 * width*height, IntPtr.Zero);
 
                gl.DrawArrays(OpenGL.GL_TRIANGLE_STRIP, 0, arrayOfVertices.Length);

Now my Question is:

Do I have to create a Vertex- and Fragmentshader and (I dont know how) to combine it with glBeginSurface(theNurb);
Maybe with
Code :
glVertexAttribPointer(1, 3, OpenGL.GL_FLOAT, false, 6 * 4, IntPtr.Zero//NurbsObject maybe???);

Or I have already created a nurbs surface:
Code :
 private void Draw()
        {
 
            glClear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            glLoadIdentity();
            glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            float[,,] ctrlpoints = new float[4, 4, 3] {
                                 { { -1.5f, 0.0f, -1.5f},  { -0.5f, 0.0f,-1.5f},  { 0.5f, 0.0f,-1.5f  },   { 1.5f, 0.0f, -1.5f} },
                                 { { -1.5f, 1.0f, -0.5f},  { -0.5f, 1.00f , -0.5f },  { 0.5f, 1.0f, -0.5f },   { 1.5f, 0.0f, -0.5f} },
                                 { { -1.5f, 0.0f,  0.5f},  { -0.5f, 1.0f, 0.5f} , { 0.5f, 0.5f,  0.5f },   { 1.5f, 0.0f,  0.5f} },
                                 { { -1.5f, 0.0f,  1.5f},  { -0.5f, 0.0f, 1.5f}, { 0.5f, 0.0f,  1.5f },    { 1.5f, 0.0f,  1.5f} }
 
            }; 
 
                theNurb = new GLUnurbsObj();
 
                //CreateGrid(4, 4);
                ////create_knots();
                gl.Rotate(rot_PosX, rot_PosY, rot_PosZ);
                gl.Translate(trans_PosX, trans_PosY, trans_PosZ);
 
                theNurb = gl.NewNurbsRenderer();
                gl.NurbsProperty(theNurb, (int)OpenGL.GLU_DISPLAY_MODE, (float)displayMode);
                //Begin drawing a NURBS surface.
                gl.BeginSurface(theNurb);
                gl.Color(1, 5, 1);
                //Draw the surface.
                gl.NurbsSurface(theNurb,      //	The internal nurbs object.
                    sKnots.Length,                  //	Number of s-knots.
                    sKnots,                         //	The s-knots themselves.
                    tKnots.Length,                  //	The number of t-knots.
                    tKnots,                         //	The t-knots themselves.
                                                    /*rowCount*/4 * 3,        //	The size of a row of control points.
                                                                              /*ColumnCount*/3,                              //	The size of a control points.
                    ToFloatArray(),   //	The control points.
                    4,            //	The order, i.e degree + 1.
                    4,           //	The order, i.e degree + 1.
                    OpenGL.GL_MAP2_VERTEX_3);           //	Type of data to generate.
                //	End the surface.
                gl.EndSurface(theNurb);
 
            }

Now here we have static controlpoints. I haven't understood what do you have to do if you have an surface with variable heights. Should I order the Controlpoints as an 1D array to exactly the same order how I would create 2 Triangles? Like (0.0,z,1.0), (0.0,z,0.0), (1.0,0.0), (1.0,1.0) ?
And where can I give my indices to the Nurbssurface that the vertices will draw in different colors?

Besides I understood if you have an surface grid for example 40x40 I have to divide it in 4x4 patches to use NurbsSurface ?

I just looking for some advices or good tutorials to create smooth NurbsSurfaces with different colors. Do we have an old way and new way to create it, like glBegin, glEnd and Shaders?

Thanks for every advice.