源代码:
#include<stdio.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include<gl/GLUT.H>
static float year = 0, day = 0;
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);//设定着色模式,使用图元中某个顶点的颜色来渲染整个图元。
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glLoadIdentity();
glPushMatrix();
gluLookAt(0.0,0.0,5,0.0,0.0,0.0,0.0,1.0,0.0);
//绘制太阳
glRotatef((GLfloat)year,0.0,1.0,0.0);
glutWireSphere(0.8,20,20);