資源簡(jiǎn)介
資源包括一個(gè)實(shí)驗(yàn)報(bào)告文檔和源程序代碼。輸入點(diǎn)的個(gè)數(shù),程序畫出相應(yīng)的貝塞爾曲線,交互操作通過控制每個(gè)點(diǎn)的移動(dòng)從而改變貝塞爾曲線的形狀

代碼片段和文件信息
#include
#include
#include
#define?MAX?20
GLfloat?ctrlpoints[MAX][3]={0.0};
//GLfloat?ctrlpoints[3][3]={{-4.0-2.00.0}{-1.00.20.0}{4.0-2.30.0}};
int?n;
void?ctrlpointsInput(void)
{
int?ij;
printf(“Please?input?the?numbers?of?the?control?points:n=?“);
scanf(“%d“&n);
printf(“Please?input?the?control?points:?\n“);
for(i=0;i {
for(j=0;j<=2;j++)
scanf(“%f“&ctrlpoints[i][j]);
}
}
void?myInit(void)
{???
ctrlpointsInput();
glClearColor(0.00.00.00.0);?
glShadeModel(GL_FLAT);??
}
void?drawline(void)
{
glMap1f(GL_MAP1_VERTEX_30.01.03n&ctrlpoints[0][0]);
glEnable(GL_MAP1_VERTEX_3);
glColor3f(1.01.01.0);???
glBegin(GL_LINE_STRIP);?????
for(int?j=0;j<=60;j++)??????
glEvalCoord1f((GLfloat)j/60.0);?
glEnd();?
}
/*void?redmark(int?e)
{
int?j=0;
glPointSize(5.0);
glBegin(GL_POINTS);
while(j!=e)?j++;
glColor3f(1.00.00.0);
glVertex3fv(&ctrlpoints[j][0]);
glEnd();
glFlush();
}*/
void?redmark(int?e)
{
glPointSize(5.0);
glBegin(GL_POINTS);
glColor3f(1.01.00.0);
for(int?j=0;j {
glColor3f(1.01.00.0);
glVertex3fv(&ctrlpoints[j][0]);
}
for(j=e+1;j {
glVertex3fv(&ctrlpoints[j][0]);
}
glColor3f(1.00.00.0);
glVertex3fv(&ctrlpoints[e][0]);
glEnd();
glFlush();
}
void?myDisplay(void)
{??
int?i;
????glClear(GL_COLOR_BUFFER_BIT);?
drawline();
glPointSize(5.0);??
glColor3f(1.01.00.0);?
glBegin(GL_POINTS);?????
for(i=0;i glVertex3fv(&ctrlpoints[i][0]);
glEnd();??
glFlush();
}?
void?reshape(int?wint?h)
{??
glViewport(00(GLsizei)w(GLsizei)h);?
glMatrixMode(GL_PROJECTION);?
glLoadIdentity();?
if(w<=h)???
glOrtho(-5.05.0-5.0*(GLfloat)h/(GLfloat)w5.0*(GLfloat)h/(GLfloat)w-5.05.0);?
else???
glOrtho(-5.0*(GLfloat)w/(GLfloat)h5.0*(GLfloat)w/(GLfloat)h-5.05.0-5.05.0);?
glMatrixMode(GL_MODELVIEW);??
glLoadIdentity();
}?
int?t=0;
void?myKeyboard(unsigned?char?keyint?x?int?y)
{
switch(key)
{
case‘j‘:
redmark((t+1)%n);
t=t+1;
break;
case‘k‘:
redmark((t-1)%n);
t=t-1;
break;
????case‘e‘:
exit(0);
??? break;
case‘w‘:
ctrlpoints[t%n][1]+=0.1;
drawline();
glutPostRedisplay();
break;
case‘s‘:
ctrlpoints[t%n][1]-=0.1;
drawline();
glutPostRedisplay();
break;
case‘a(chǎn)‘:
ctrlpoints[t%n][0]-=0.1;
drawline();
glutPostRedisplay();
break;
case‘d‘:
ctrlpoints[t%n][0]+=0.1;
drawline();
glutPostRedisplay();
break;
????? default:
????? break;
}
}
int?main(int?argcchar**argv)
{??
glutInit(&argcargv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500500);
glutInitWindowPosition(100100);
glutCreateWindow(“貝塞爾曲線的繪制“);
myInit();
glutDisplayFunc(myDisplay);
glutReshapeFunc(reshape);
????glutKeyboardFunc(myKeyboard);
glutMainLoop();
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????4344??2012-12-09?15:19??project-02周游2010213445\beziercurve\beziercurve.dsp
?????文件????????530??2012-12-09?14:20??project-02周游2010213445\beziercurve\beziercurve.dsw
?????文件??????33792??2012-12-09?15:19??project-02周游2010213445\beziercurve\beziercurve.ncb
?????文件??????48640??2012-12-09?15:19??project-02周游2010213445\beziercurve\beziercurve.opt
?????文件???????1049??2012-12-09?14:46??project-02周游2010213445\beziercurve\beziercurve.plg
?????文件???????2949??2012-12-11?15:08??project-02周游2010213445\beziercurve\beziervurve.cpp
?????文件???????3461??2012-12-15?15:39??project-02周游2010213445\beziercurve\beziervurve.dsp
?????文件????????530??2012-12-15?15:39??project-02周游2010213445\beziercurve\beziervurve.dsw
?????文件??????41984??2012-12-15?15:39??project-02周游2010213445\beziercurve\beziervurve.ncb
?????文件??????48640??2012-12-15?15:39??project-02周游2010213445\beziercurve\beziervurve.opt
?????文件????????779??2012-12-15?15:39??project-02周游2010213445\beziercurve\beziervurve.plg
?????文件?????192582??2012-12-09?14:36??project-02周游2010213445\beziercurve\Debug\beziercurve.exe
?????文件?????229924??2012-12-09?14:36??project-02周游2010213445\beziercurve\Debug\beziercurve.ilk
?????文件?????340124??2012-12-09?14:20??project-02周游2010213445\beziercurve\Debug\beziercurve.pch
?????文件?????451584??2012-12-09?14:36??project-02周游2010213445\beziercurve\Debug\beziercurve.pdb
?????文件?????208966??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\beziervurve.exe
?????文件?????337992??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\beziervurve.ilk
?????文件??????14593??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\beziervurve.obj
?????文件?????353580??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\beziervurve.pch
?????文件?????492544??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\beziervurve.pdb
?????文件??????41984??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\vc60.idb
?????文件??????45056??2012-12-15?15:39??project-02周游2010213445\beziercurve\Debug\vc60.pdb
?????文件???????2949??2012-12-27?18:46??project-02周游2010213445\chengxu.txt
?????文件????1136640??2012-12-28?15:41??project-02周游2010213445\OPENGL報(bào)告T.ppt
?????文件??????33792??2012-12-30?19:59??project-02周游2010213445\曲線\Debug\vc60.idb
?????文件??????53248??2012-12-30?19:55??project-02周游2010213445\曲線\Debug\vc60.pdb
?????文件?????204856??2012-12-30?19:55??project-02周游2010213445\曲線\Debug\曲線.exe
?????文件?????269792??2012-12-30?19:55??project-02周游2010213445\曲線\Debug\曲線.ilk
?????文件??????16224??2012-12-30?19:55??project-02周游2010213445\曲線\Debug\曲線.obj
?????文件?????339984??2012-12-30?19:51??project-02周游2010213445\曲線\Debug\曲線.pch
............此處省略16個(gè)文件信息
評(píng)論
共有 條評(píng)論