# [Solved] Bezier curves and GL_POLYGON

## Recommended Posts

alef    100
Hello, I would like to create a complex surface thanks to two bezier curves but I encounter a technical problem : glMap1f() cannot be called inside a GL_POLYGON block, so I cannot "load" my other control points and evaluate the next bezier curve..... Here is a the bad code, but it can help you understand what I want to do :
int i;

GLfloat FirstCtrlPoints[4][3] = {{,,} ......};
GLfloat SecondCtrPoints[4][3] = {{,,}......};

glColor3ub(255, 0, 0);

glBegin(GL_POLYGON);

glMap1f(GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 4, &FirstCtrlPoints[0][0]);
glEnable(GL_MAP1_VERTEX_3);

for(i = 1; i <= 100; i++)
glEvalCoord1f ((float)i / 100.0f);

glMap1f(GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 4, &SecondCtrlPoints[0][0]);
glEnable(GL_MAP1_VERTEX_3);

for(i = 1; i <= 100; i++)
glEvalCoord1f ((float)i / 100.0f);

glEnd();

glColor3ub(255, 255, 255);


Do you think there is a way to evaluate two bezier curves inside one unique GL_POLYGON block ? Thank you very much, [Edited by - alef on March 19, 2010 7:52:12 AM]

##### Share on other sites
phyxle    100

I would suggest that you use one set of control points by combining the two sets. If you need sharp edges when you connect two curves you can repeat control points at those locations.
Another solution is calculating the vertices yourself which is very easy.
Another solution is to use two polygons. You can properly connect them by adding additional vertices at the beginning and the end of each polygon. Placing these additional points halfway between the beginning vertex of one polygon and last vertex of the other one might give the results that you are looking for.
However, keep in mind that you can only draw convex polygons with GL_POLYGON.

##### Share on other sites
alef    100

I'm going to make my own bezier function, it would be a lot easier ;-)

thanks,