// OpenGL_Prac.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <gl/glut.h> #include <math.h> #define C_PI 3.14159265358979 GLdouble distanceSunToEarth = 70;//日地距离 GLdouble distanceMoonToEarth = 35;//月地距离 GLdouble gzAngleEarth = 0;//地球绕太阳的公转角度 GLdouble gzAngleMoon = 0;//月球绕地球的公转角度 GLsizei zzAngle = 0;//自转角度 int earthX = distanceSunToEarth; int earthY = 0; int earthZ = 0; int moonX = distanceSunToEarth + distanceMoonToEarth; int moonY = 0; int moonZ = 0; void drawPlanet(int r, GLdouble x0, GLdouble y0, GLdouble z0 ) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glRotatef(70.0 , 1.0, 0.0, 0.0); glTranslatef(x0, y0, z0); glRotatef(zzAngle, 0.0, 0.0, 1.0); glutWireSphere(r, 30, 10); glPopMatrix(); } void init() { glClearColor(0.0, 0.0 , 0.0, 0.0); glShadeModel(GL_FLAT); } void re