#include "stdio。h"
#ifdef __APPLE__
#include 〈GLUT/glut。h〉
#else
#include <GL/glut.h>
#endif
#include 〈stdlib.h>
#include <stdio。h〉
#include <math.h〉
#include 〈windows.h〉
#include 〈time。h〉
static double a=0;
static double b=0.2;
static double t=0;
static double t1=0;
static double v=0;
static double i=0;
static double m=0;
static double n=0;
static double p,q,r,r1=1;
static void resize(int width,int height)//重绘回调函数
{
const float ar=(float)width/(float)height;
glViewport(0,0,width,height);//利用函数glViewport定义视区
glMatrixMode(GL_PROJECTION);//投影矩阵
glLoadIdentity();// 重置坐标系统,使投影变换复位
glFrustum(-ar,ar,—1。0,1。0,2。0,100.0);//利用函数glFrustum定义修剪区
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void display(void)//显示回调
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//清除颜色缓冲区和深度缓冲区
t=t+t1*0.0001;
glColor3d(1,0。6,0.6);//画图颜色灰红
//绘制一个实心球,默认原点在屏幕中心与照相机重合
glPushMatrix();
glTranslated(—3+0。5*cos(a),-0.6+0。5*sin(a),-5);
glRotated(0,0,0,0);
glutSolidSphere(b,16,16);
glPopMatrix();
glColor3d(1,0,0);//画图颜色红
//绘制一个实心球,默认原点在屏幕中心与照相机重合
glPushMatrix();
glTranslated(—3+t*cos(a)*v*t1,-0。6+(t*sin(a)*v—45*t*t)*t1,—5);
glRotated(0,0,0,0);
glutSolidSphere(0。2*r1,16,16);
glPopMatrix();
glColor3d(1,1,1);//画图颜色灰
//绘制一个线框圆环
glPushMatrix();
glTranslated(m+2。3,n—0。6,-5);