计算机绘图雪人

计算机绘图雪人

ID:39505810

大小:29.00 KB

页数:3页

时间:2019-07-04

计算机绘图雪人_第1页
计算机绘图雪人_第2页
计算机绘图雪人_第3页
资源描述:

《计算机绘图雪人》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、#includestaticGLfloatxRot=0.0f;staticGLfloatyRot=0.0f;voidReshape(intw,inth){glClear(GL_COLOR_BUFFER_BIT

2、GL_DEPTH_BUFFER_BIT);glClearColor(0.5f,0.5f,1.0f,0.5f);GLfloatScale;if(h==0)h=1;glViewport(0,0,w,h);Scale=(GLfloat)w/(GLfloat)h;glMatrixMode(GL_PROJECT

3、ION);glLoadIdentity()gluPerspective(40.0f,Scale,1.0,40.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}voidSpecialKeys(intkey,intx,inty){if(key==GLUT_KEY_UP)xRot-=1.0f;if(key==GLUT_KEY_DOWN)xRot+=1.0f;if(key==GLUT_KEY_LEFT)yRot-=1.0f;if(key==GLUT_KEY_RIGHT)yRot+=1.0f

4、;xRot=(GLfloat)((constint)xRot%360);yRot=(GLfloat)((constint)yRot%360);glutPostRedisplay();}voidDisplay(void){GLUquadricObj*pObj;glClear(GL_COLOR_BUFFER_BIT

5、GL_DEPTH_BUFFER_BIT);glPushMatrix();glTranslatef(0.0f,-1.0f,-5.0f);glRotatef(xRot,1.0f,0.0f,0.0f);glRotatef(yR

6、ot,0.0f,1.0f,0.0f);pObj=gluNewQuadric();gluQuadricNormals(pObj,GLU_SMOOTH);//MainBodyglPushMatrix();glColor3f(1.0f,1.0f,1.0f);gluSphere(pObj,.40f,26,13);//BottomglTranslatef(0.0f,.550f,0.0f);//MidsectiongluSphere(pObj,.3f,26,13);glTranslatef(0.0f,0.45f,0.0f);//Headgl

7、uSphere(pObj,0.24f,26,13);//EyesglColor3f(0.0f,0.0f,0.0f);glTranslatef(0.1f,0.1f,0.21f);gluSphere(pObj,0.02f,26,13);glTranslatef(-0.2f,0.0f,0.0f);gluSphere(pObj,0.02f,26,13);//NoseglColor3f(1.0f,0.3f,0.3f);glTranslatef(0.1f,-0.12f,0.0f);gluCylinder(pObj,0.04f,0.0f,0.

8、3f,26,13);glPopMatrix();//HatglPushMatrix();glColor3f(0.0f,0.0f,0.0f);glTranslatef(0.0f,1.17f,0.0f);glRotatef(-90.0f,1.0f,0.0f,0.0f);gluCylinder(pObj,0.17f,0.17f,0.4f,26,13);//HatbrimglDisable(GL_CULL_FACE);gluDisk(pObj,0.17f,0.28f,26,13);glEnable(GL_CULL_FACE);glTra

9、nslatef(0.0f,0.0f,0.40f);gluDisk(pObj,0.0f,0.17f,26,13);glPopMatrix();glPopMatrix();glutSwapBuffers();}intmain(intargc,char*argv[]){glutInit(&argc,argv);glutInitDisplayMode(GLUT_DOUBLE

10、GLUT_RGB

11、GLUT_DEPTH);glutInitWindowSize(800,600);glutCreateWindow("Snowman");glutR

12、eshapeFunc(Reshape);glutSpecialFunc(SpecialKeys);glutDisplayFunc(Display);glutMainLoop();return0;}

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。