Page 294 OpenGL Super Bible! Notice (Web site designers) that this
Page 294 OpenGL Super Bible! Notice that this code always returns a palette. No check is made to see if the pixel format required a palette. This is because you can use color index mode even in the high-color modes. All of the other code concerning palette realization remains unaffected. Show the Triangle Now the code to render the triangle sets the color of the triangle s apex to color index 0, which is the darkest entry in the palette with 0 intensity (black). The color for the bottom two corners is set to palette index 255, the brightest shade of red. With smooth shading enabled, this code (Listing 8-7) produces the triangle seen in Figure 8-15. Listing 8-7 Code to render the shaded triangle in the INDEX program void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT); // Enable smooth shading glShadeModel(GL_SMOOTH); // Draw the triangle glBegin(GL_TRIANGLES); // Darkest Red Apex (black) glIndexi(0); glVertex3f(0.0f,200.0f,0.0f); // Brightest red bottom corners glIndexi(255); glVertex3f(200.0f,-70.0f,0.0f); glVertex3f(-200.0f, -70.0f, 0.0f); glEnd(); // Flush drawing commands glFlush(); }
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.