//A.19 Bezier曲线程序
/* curves.c */
/*
**
** Bezier curve drawing program.
**
** q - Quit the program
** c - Clear the screen
** e - Erase the curves
** b - Draw Bezier curves
**
*/
#include <GL/glut.h>
#include<Windows.h>
void keyboard(unsigned char key, int x, int y);
#define MAX_CPTS 25 /* Fixed maximum number of control
points */
GLfloat cpts[MAX_CPTS][3];
int ncpts = 0;
static int width = 500, height = 500; /* Window width and
height */
static void drawCurves()
{
int i;
for(i=0;i<ncpts-3;i+=3)
{
/* draw the curve using OpenGL evaluators */
glMap1f(GL_MAP1_VERTEX_3,0.0,1.0,3,4,cpts[i]);
glMapGrid1f(30,0.0,1.0);
glEvalMesh1(GL_LINE,0,30);
}
glFlush();
}
static void display(void)
{
int i;
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
for (i = 0; i < ncpts; i++)
glVertex3fv(cpts[i]);
glEnd();
glFlush();
}
void mouse(int button, int state, int x, int y)
{
float
[OpenGL]课后案例19:Bezier曲线程序
最新推荐文章于 2021-04-06 20:08:56 发布
