计算机图形学(OpenGL技术)太阳系动画

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includegl/glut.h#includestdlib.hfloatfEarth=2.0f;floatfMood=24.0f;voidInit(){glEnable(GL_DEPTH_TEST);glClearColor(0.0f,0.0f,0.0f,0.8f);}voidDisplay(){glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glMatrixMode(GL_MODELVIEW);glLoadIdentity();//»­Ì«ÑôglTranslated(0.0f,0.0f,-500.0f);glColor3f(1.0f,0.0f,0.0f);glutSolidSphere(50,20,20);//»­µØÇòglColor3f(0.0f,0.0f,1.0f);glRotatef(23.27,0.0f,0.0f,1.0f);glRotatef(fEarth,0.0f,1.0f,0.0f);glTranslated(200.0f,0.0f,0.0f);glutSolidSphere(20.0,10,16);//»­ÔÂÇòglPopMatrix();glPopMatrix();glRotatef(6.0,1.0f,1.0f,1.0f);glRotatef(fMood,0.0f,1.0f,0.0f);glTranslated(30.0f,0.0f,0.0f);glColor3f(1.0f,1.0f,0.0f);glutSolidSphere(5,20,20);glLoadIdentity();glFlush();glutSwapBuffers();}voidmyIdle(){fEarth+=0.03;if(fEarth360.0f)fEarth=0.2f;fMood+=0.24f;if(fMood360.0f)fMood=24.0f;Display();}voidreshape(intw,inth){if(h==0)h=0;glViewport(0,0,w,h);//ÉèÖÃÊÓÇø´óСglMatrixMode(GL_PROJECTION);//glLoadIdentity();gluPerspective(45.0f,w/h,1.0f,1000.0f);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}intmain(intargc,char**argv){glutInit(&argc,argv);glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);glutInitWindowSize(500,500);glutCreateWindow(Ì«Ñôϵ¶¯»­);glutDisplayFunc(Display);glutReshapeFunc(reshape);glutIdleFunc(&myIdle);Init();glutMainLoop();return0;}

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功