include gl glut GLUquadricObj theqw void init glClearColor 98 theqw gl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <gl/glut.h>
GLUquadricObj* theqw;
void init() {
glClearColor(0.1, 0.98, 0.3, 1);
theqw = gluNewQuadric();
glEnable(GL_DEPTH_TEST);
//glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
}
void Display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRotatef(1.0, 1.0, 1.0, 1.0);
glColor3f(1, 0, 0);
gluSphere(theqw, 0.3, 50, 50);
glutPostRedisplay();
glutSwapBuffers();
}
void main() {
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(480, 480);
glutInitWindowPosition(100, 100);
glutCreateWindow(" ");
init();
glutDisplayFunc(Display);
glutMainLoop();
}