include gl glut include stdio Gl_AMBIENT GL_DIFFUSE GL_SPECULAR GLUqua

 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <gl/glut.h>
#include <stdio.h>
//Gl_AMBIENT;
//GL_DIFFUSE;
//GL_SPECULAR;
GLUquadricObj* theqw;
GLfloat ModelAmbient[] = {1.0,1.0,1.0,1.0};
GLfloat white_light[] = {1.0, 0.0, 0.0, 1.0};
GLfloat lightposition[] = {0,0,10,0};
void init()
{
glClearColor (0.0, 0.0, 0.0, 1);
theqw = gluNewQuadric();
glEnable(GL_DEPTH_TEST);
//glEnable(GL_COLOR_MATERIAL);
glLightfv(GL_LIGHT0, GL_AMBIENT, white_light);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ModelAmbient);
glLightfv(GL_LIGHT0, GL_POSITION, lightposition);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(-5,5,-5,5,5,15);
glFrustum(-5,5,-5,5,5,15);
glMatrixMode(GL_MODELVIEW);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
glFrontFace(GL_CW);
}
void Display()
{
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glRotatef(300000.0,1.0,1.0,300000.0);
glRotatef(3.0,1.0,1.0,3.0);
glColor3f(2,1,0);
glPushMatrix();
glTranslated(0,0,-10);
glRotatef(1.0,1.0,1.0,1.0);
glutWireTeapot(3);
glPopMatrix();
//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();
}