资源预览内容
第1页 / 共3页
第2页 / 共3页
第3页 / 共3页
亲,该文档总共3页全部预览完了,如果喜欢就下载吧!
资源描述
/ homework3_l .cpp : Defines the entry pomt for the console application. /#include Hstdafx.hH#mclude#iiiclude#inc lude#mclude#iiiclude#iiiclude#iiicludeiiit widejieight;iiit lefthit=O;float x4=25J00,150,250,y4=25J25,175,50;void reshape(mt w, int h)wide = w;height = h;glVi亡wport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadldentitvQ;gluOrtho2D(w2w/2,h2h/2); glMatrixMode(GL-MODELVIEW); glLoadldentitvQ;iiit zuhe(iiit n.iiit k)int i、sl,s2;sl=l;s2=l;if(k=O) retuin 1; fbr(i=n;i=n-k+l;i) sl=sl*i;fbr(i=k;i=2;i) s2=s2*i;return sl/s2;float faiig(float njnt k)if(k=O) retuin 1;retuin pow(n,k);float beiikii(mt njnt k,float t)retuin zuhe(n,k)*faiig(t,k)*fang(l -tji-k); void Init(void)glCleaiColor( 1.0,1.0,1.0,0.0);void displav(void) glCleai(GL_COLOR_BUFFER_BIT);glPointSize(S.O);glColoi3f(1.0f.0.00.0f);float xlll5ylllJll=0,s=0.0; int i;fbr(i= l;ill ;i+) s=s+0 1 ;ti=s;fdi(i=O;ill;i+)xli=x0*benkn(3.0,ti)+xl*beiikii(3J,ti)-rx2*beiikii(3,2,ti)+x3*beiikii(3,3ji);yli=y0*benkii(3.0ji)+yl*benkn(3J.ti)+y2*beiikii(3,2,ti)-ry3*beiikii(3,3,ti);glBegm(GL_POINTS);glVertex2f(x0,y0); glVertex2f(xl,yl); glVertex2f(x2,y2); glVertex2f(x3,y3); glEnd();glB 亡 gin(GL_LINE_STRIP);fbr(i=O;ill;i+) glVenex2f(xli,yli); glEnd();glFlushQ; void mouse(int key.iiit statejnt m,mt n)if (leftlut=O) glCbai(GL_COLOR_EUFFER_EIT); mt i=O;glColor3f(1.0f0.0f.0.0f);if (key=GLUT-LEFT_BUTTON&sta = GLUT_DOWN) glBegm(GL_POINTS);fbr(i=lefthit;i=4)displavO;leftliit=O:void main(mt aigc.chai * argv)glutlnit( &aigc,a【gv); gluthiitDisplavMode(GLUT_SINGLE|GLUT_RGB); glutInitWmdowSize(640.480);glutInitWmdowPosition( 100,150); glutCreateWmdow(H 贝塞尔曲线 J; glutReshapeFunc(ieshape); glutDisplayFunc(displav);glutMouseFunc(mouse);Ink(); glutManiLoopQ;
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号