Page 314 OpenGL Super Bible! The earlier code
Page 314 OpenGL Super Bible! The earlier code fragment setting material properties would then be as follows. This looks like more code, but it will actually save many lines of code and execute faster as the number of polygons grows. // Enable color tracking glEnable(GL_COLOR_MATERIAL); // Front material ambient and diffuse colors track glColor glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gray); glcolor3f(0.75f, 0.75f, 0.75f); glBegin(GL_TRIANGLES); glVertex3f(-15.0f,0.0f,30.0f); glVertex3f(0.0f, 15.0f, 30.0f); glVertex3f(0.0f, 0.0f, -56.0f); glEnd(); Listing 9-1 contains the code we add with the SetupRC function to our JET example, to set up a bright ambient light source, and to set the material properties that allow the object to reflect light and be seen. We have also changed the colors of the jet so that each section is a different color rather than each polygon. Notice in the final output (Figure 9-7) that it s not much different from the image before we had lighting. However, if we reduce the ambient light by half, we get the image shown in Figure 9-8. This is accomplished by setting the ambient light RGBA values to the following: GLfloat ambientLight[] = { 0.5f, 0.5f, 0.5f, 1.0f }; Figure 9-7 Output from completed AMBIENT example program
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.