#include
#include
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);
}
void myDisplay()
{
float x0 = 50, y0 = 50;
float x1 = 100, y1 = 400;
float x2 = 300, y2 = 400;
float x3 = 400, y3 = 50;
glPointSize(3);
glColor3f(1.0, 0.0, 0.0);
//控制点
glBegin(GL_POINTS);
glVertex2f(x0, y0);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glVertex2f(x3, y3);
glEnd();
//三次Bezier曲线
float x, y;
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_LINE_STRIP);
for (float t = 0; t <= 1; t+=0.01)
{
x = x0 * pow((1 - t), 3) + 3 * x1*t*(1 - t)*(1 - t) +