The question about the curve in OpenGL on the XP System

Source: Internet
Author: User

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); 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.