一直显示 error C2065: “knots” : undeclared identifier 这个错误,本人也知道是knots未定义,但是怎么定义啊
求个高手解答,要详细一些怎么改能解决
求个高手解答,要详细一些怎么改能解决
#include <windows.h> #include <GL/glut.h> GLUnurbsObj *theNurb; GLfloat ctrlpoints[9][3] = {{0,-0.2,0},{-1.2,-0.5,0},{-1.6,-1,0},{-1.4,-1.5,0}, {-1,-2.2,0},{-0.5,-2.7,0},{-0.35,-3.2,0},{-0.6,-3.7,0},{-1.6,-4.2,0}};//控制点 GLfloat color[9][3]={{1.0,0.0,0.0},{1.0,1.0,0.0},{0.0,1.0,0.0},{-1.0,1.0,0.0}, {-1.0,0.0,0.0},{-1.0,-1.0,0.0},{0.0,-1.0,0.0},{1.0,-1.0,0.0},{1.0,-1.0,0.0}}; void myInit(void) { glClearColor(1.0,1.0,1.0,0.0);//设置背景色 theNurb = gluNewNurbsRenderer();//创建NURBS对象theNurb gluNurbsProperty(theNurb,GLU_SAMPLING_TOLERANCE,10); } /*绘制曲线*/ void myDisplay(void) { int i; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(0.0,0.0,0.0); glLineWidth(3.0); /*绘制曲线*/ gluBeginCurve(theNurb); gluNurbsCurve(theNurb,13,knots,3,&ctrlpoints[0][0],4,GL_MAP1_VERTEX_3); gluNurbsCurve(theNurb,13,knots,3,&color[0][0],4,GL_MAP1_COLOR_4); gluEndCurve(theNurb); /*绘制点*/ glColor3f(1.0,0.0,0.0); glPointSize(5.0); glBegin(GL_POINTS); for(i = 0;i < 9;i++) glVertex2fv(&ctrlpoints[i][0]); glEnd(); glutSwapBuffers(); } void myReshape(GLsizei w,GLsizei h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(w <=h) glOrtho(-10.0,10.0,-10.0*(GLfloat)h/(GLfloat)w,10.0*(GLfloat)h/ (GLfloat)w,-10.0,10.0); else glOrtho(-10.0*(GLfloat)w/(GLfloat)h,10.0*(GLfloat)w/(GLfloat)h,- 10.0,10.0,-10.0,10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0,0.0,-9.0); } int main(int argc,char ** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); glutInitWindowSize(600,400); glutInitWindowPosition(200,200); glutCreateWindow("NURBS curve"); /*绘制与显示*/ myInit(); glutReshapeFunc(myReshape); glutDisplayFunc(myDisplay); glutMainLoop(); return(0); }
解决方案
60
例如:GLfloat knots[13] = {1,2,3,….};