这是一个类似于地球绕太阳旋转的demo

原有的例子是用键盘接受事件,我做了修改,使用了timer把他变成一个动态旋转的

#import <Foundation/Foundation.h>
#include <GLUT/GLUT.h>
static int year=,day=;
void init()
{
glClearColor(,,,);
glShadeModel(GL_FLAT);
} void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(,,);
glPushMatrix();
glutWireSphere(,,);
glRotatef((GLfloat)year,,,);
glTranslated(,,); glRotatef((GLfloat)day,,,);
glutWireSphere(0.2,,);
glPopMatrix();
glutSwapBuffers(); } void reshape(int w,int h)
{
glViewport(, , (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); gluPerspective(,(GLfloat)w/(GLfloat)h,,);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(,,,,,,,,);
} void fishboard()
{
day=(day+)%;
year=(year+)%;
glutPostRedisplay();
} void timerProc(int id)
{
fishboard();
glutTimerFunc(,timerProc,);//需要在函数中再调用一次,才能保证循环
} int main(int argc,char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(, );
glutInitWindowPosition(,);
glutCreateWindow("Xcode Glut Demo");
init(); glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutTimerFunc(,timerProc,); glutMainLoop();
return ;
}

最新文章

  1. Android开发中上线后修改应用名称的若干问题
  2. jquery parent和parents的区别
  3. Kafka集群部署
  4. OSG绘制几何图形
  5. 图解CISCO 3550忘记密码解决方法
  6. codeforces #305 A Mike and Frog
  7. Web版RSS阅读器(三)——解析在线Rss订阅
  8. C socket demo
  9. VMware 虚拟机(linux)增加根目录磁盘空间 转自
  10. sass安装步骤
  11. Android - Get Bluetooth UUID for this device
  12. 安卓handler、thread实现异步任务
  13. ssh用法及命令
  14. python输入字符串
  15. HD,3G视频数据中行号的插入方法---Verilog代码实现
  16. centos6.8 固定IP
  17. Python开发——面向对象【类、实例】
  18. 发布库到仓库 maven jcenter JitPack MD
  19. Spark2.0.0源码编译
  20. SpringBoot(四)-- 整合Servlet、Filter、Listener

热门文章

  1. 查看 EGLIBC 版本
  2. managed unmanaged
  3. day05 模块以及内置常用模块用法
  4. 大数据学习——spark运营案例
  5. FastText 介绍
  6. (英文排版测试)Lorem Ipsum
  7. 深度学习:Sigmoid函数与损失函数求导
  8. Farey sequences
  9. List容器——LinkedList及常用API,实现栈和队列
  10. C#委托实现异步