#include
#include
GLfloat light_diffuse []={1.0, 0.0, 0.5, 1.0};/* Red diffuse light. */
GLfloat light_position []={1.0, 0.0, 1.0, 0.0};/* Infinite light location. */
GLfloat v [8] [3]./* Will be filled in with the X, Y, Z vertexes. */
Void
The display (void)
{
GlClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GlutSolidSphere (1100100);
GlutSolidTeapot (1);
GlutSwapBuffers ();
}
Void
Init (void)
{
/* the Enable a single OpenGL light. */
GlLightfv (GL_LIGHT0 GL_DIFFUSE, light_diffuse);
GlLightfv (GL_LIGHT0 GL_POSITION, light_position);
GlEnable (GL_LIGHT0);
GlEnable (GL_LIGHTING);
/* Use the depth the buffering for hidden surface elimination. */
GlEnable (GL_DEPTH_TEST);
/* Setup the view of the cube. */
GlMatrixMode (GL_PROJECTION);
GluPerspective (/* field of view in degree */40.0,
/* aspect thewire */1.0,
/* Z near */1.0,/* far */Z 10.0);
GlMatrixMode (GL_MODELVIEW);
GluLookAt (0.0, 2.0, 8.0, eye is at (0,0,8)/* */
0.0, 0.0, 0.0, the center is at (0, 0)/* */
0.0, 1.0, 0.);/* up is in the positive Y direction */
/* Adjust cube position to be asthetic Angle. */
GlTranslatef (0.0, 0.0, 1.0);
GlRotatef (45, 1.0, 0.3, 1.0);
GlRotatef (0, 0.0, 0.0, 1.0);
}
Int
The main (int arg c, char * * argv)
{
GlutInit (& amp; Arg c, argv);
GlutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
GlutInitWindowSize (800, 600);
GlutCreateWindow (" 111 ");
GlutDisplayFunc (display);
init();
GlutMainLoop ();
return 0;/* the ANSI C requires the main to return int. J */
}