Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nurbs曲面不会显示在openGL中_Opengl_Glu - Fatal编程技术网

nurbs曲面不会显示在openGL中

nurbs曲面不会显示在openGL中,opengl,glu,Opengl,Glu,上述代码不起作用。drawNurbs函数中存在错误。但我不知道我错在哪里。Ctpoint[]的大小为225*3。我发现了问题 1前4个结元素为0 2节数应为15+4=19,而不是229 GLUnurbsObj *theNurb; theNurb = gluNewNurbsRenderer(); gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 5.0); gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, G

上述代码不起作用。drawNurbs函数中存在错误。但我不知道我错在哪里。Ctpoint[]的大小为225*3。

我发现了问题

1前4个结元素为0

2节数应为15+4=19,而不是229

GLUnurbsObj *theNurb;

theNurb = gluNewNurbsRenderer();
gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 5.0);
gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);

//ctrPoint[] is an array containing the coordinate x,y,z of a grid size of 15*15. 
// therefore, the # of control points is 15*15=225. The degree is 3 and
// the order is 4.The size of knot vector is 4+225 = 229.   

void drawNurbs(){
    float knots[229];
    for (int i=0;i<114;i++)
    {
        knots[i] = 0;
    }
    for (int i=114;i<229;i++)
    {
        knots[i] = 1;
    }

    gluBeginSurface(theNurb);
    gluNurbsSurface(theNurb, 229, knots, 229, knots, 15*3 , 3, &ctrPoint[0], 
        4, 4, GL_MAP2_VERTEX_3);
    gluEndSurface(theNurb);

}

void display(){
    drawNurbs();
}
然后

GLfloat ctrlpoints[s_count][t_count][type]; //ctrlPoints[15][15][3]
GLfloat sknot[sknot_count];                 
GLfloat tknot[tknot_count];
sknot_count = s_count + sorder; // 19 = 15+4
tknot_count = t_count + torder; // 19=15+4