Page 344 OpenGL Super Bible! Listing 9-12 Render the jet and its shadow // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Save the matrix state and do the rotations glPushMatrix(); // Draw jet at new orientation, put light in correct position // before rotating the jet glLightfv(GL_LIGHT0,GL_POSITION,lightPos); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); DrawJet(FALSE); // Restore original matrix state glPopMatrix(); // Get ready to draw the shadow and the ground // First disable lighting and save the projection state glPushAttrib(GL_LIGHTING_BIT); glDisable(GL_LIGHTING); glPushMatrix(); // Multiply by shadow projection matrix glMultMatrixf((GLfloat *)shadowMat); // Now rotate the jet around in the new flattened space glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); // Pass true to indicate drawing shadow DrawJet(TRUE); // Restore the projection to normal glPopMatrix(); // Draw the light source glPushMatrix(); glTranslatef(lightPos[0],lightPos[1], lightPos[2]); glRGB(255,255,0); auxSolidSphere(5.0f); glPopMatrix(); // Draw the ground; we do manual shading to a darker green // in the background to give the illusion of depth glBegin(GL_QUADS); glRGB(0,128,0); glVertex3f(400.0f, -150.0f, -200.0f); glVertex3f(-400.0f, - 150.0f, -200.0f);
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.