#include <GL/glut.h>
#include <stdio.h>
#include <time.h>
// 太阳、地球和月亮
// 假设每个月都是12天
// 一年12个月,共是360天
static int day = 200; // day的变化:从0到359
double CalFrequency()
{
static int count;
static double save;
static clock_t last, current;
double timegap;
++count;
if( count <= 50 )
return save;
count = 0;
last = current;
current = clock();
timegap = (current-last)/(double)CLK_TCK;
save = 50.0/timegap;
return save;
}
void myDisplay(void)
{
double FPS = CalFrequency();
printf("FPS = %f\n", FPS);
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(75, 1, 1, 400000000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, -200000000, 200000000, 0, 0,
[OpenGL]一个简单的地球月亮太阳运转模型
最新推荐文章于 2021-01-15 18:32:49 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)