Today, we use OpenGL to draw bezr curves, but when I increase the number of control points to nine, the program will not be able to draw images.
Later, after some tossing, I finally realized that it was a problem with the XP system and the program could run normally on Windows 7.
I will attach my main program below
The first section uses glevalcoord1f ()
The function is converted into discrete points and then linked in a straight line.
glShadeModel(GL_FLAT); glColor3f(1.0,0.0,0.0);GLfloat controlPoint[9][3] = {{-1.0f,0.0f,0.0f},{-0.75f,0.707f,0.0f},{-0.5f,1.0f,0.0f},{-0.25f,0.707f,0.0f},{0.0f,0.0f,0.0f},{0.25f,-0.707f,0.0f},{0.5f,-1.0f,0.0f},{0.75f,-0.707f,0.0f},{1.0f,0.0f,0.0f}};glMap1f(GL_MAP1_VERTEX_3,0.0,1.0,3,8,(const float*)controlPoint);glEnable(GL_MAP1_VERTEX_3);glBegin(GL_LINE_STRIP);for(int i = 0;i <= 100; i++)glEvalCoord1f((GLfloat)i/(GLfloat)100.0);glEnd();glDisable(GL_MAP1_VERTEX_3);
The second segment uses glmapgrid1d (); To perform automatic equality for the U parameter. Use the glevalmesh1 () function to generate a series of points and use these vertex coordinates to draw a curve.
glShadeModel(GL_FLAT); glColor3f(1.0,0.0,0.0);GLfloat controlPoint[9][3] = {{-1.0f,0.0f,0.0f},{-0.75f,0.707f,0.0f},{-0.5f,1.0f,0.0f},{-0.25f,0.707f,0.0f},{0.0f,0.0f,0.0f},{0.25f,-0.707f,0.0f},{0.5f,-1.0f,0.0f},{0.75f,-0.707f,0.0f},{1.0f,0.0f,0.0f}};glMap1f(GL_MAP1_VERTEX_3,0.0,1.0,3,8,(const float*)controlPoint);glEnable(GL_MAP1_VERTEX_3);glMapGrid1f(50,0.0f,1.0f);glEvalMesh1(GL_LINE,0,50);glDisable(GL_MAP1_VERTEX_3);