
*/ void keyPressed( unsigned char key, int x, int y) * The function called whenever a key is pressed. Rquad -=15.0f // Decrease The Rotation Variable For The Quad // swap the buffers to display, since double buffering is used. Rtri +=0.005f // Increase The Rotation Variable For The Triangle if(rtri >2) GlEnd() // we're done with the polygon (smooth color interpolation) GlColor3f( 0.0f, 0.0f, 1.0f) // Set The Color To Blue

GlColor3f( 0.0f, 1.0f, 0.0f) // Set The Color To Green GlColor3f( 1.0f, 0.0f, 0.0f) // Set The Color To Red GlBegin(GL_POLYGON) // start drawing a polygon GlTranslatef(rtri, 0.0f, -6.0f) // Move Left 1.5 Units And Into The Screen 6.0 //glRotatef(rtri,1.0f,0.0f,0.0f) // Rotate The Triangle On The Y axis // draw a triangle (in smooth coloring mode) GlClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) // Clear The Screen And The Depth Buffer GlTranslatef(ballX +1.5,ballY,ballZ) //moving it toward the screen a bit on creation GlutSolidSphere ( 0.3, 20, 20) //create ball. GlTranslatef(ballX,ballY,ballZ) //moving it toward the screen a bit on creation //glRotatef(ballX,ballX,ballY,ballZ) GlViewport( 0, 0, Width, Height) // Reset The Current Viewport And Perspective Transformation If (Height =0) // Prevent A Divide By Zero If The Window Is Too Small * The function called when our window is resized (which shouldn't happen, because we're fullscreen) */ void ReSizeGLScene( int Width, int Height) GlLoadIdentity() // Reset The Projection Matrix

GlShadeModel(GL_SMOOTH) // Enables Smooth Color Shading

GlEnable(GL_DEPTH_TEST) // Enables Depth Testing GlDepthFunc(GL_LESS) // The Type Of Depth Test To Do GlClearDepth( 1.0) // Enables Clearing Of The Depth Buffer This Will Clear The Background Color To Black */ // We call this right after our OpenGL window is created. * A general OpenGL initialization function. */ #define ESCAPE 27 /* The number of our GLUT window */ int window #include // Header File For The GLUT Library #include // Header File For The OpenG元2 Library #include // Header File For The GLu32 Library //#include // Header File For sleeping.
