Top ten web hosting - OpenGL Super Bible! Page 285 // This window

OpenGL Super Bible! Page 285 // This window may set the palette, even though it is not the // currently active window. case WM_PALETTECHANGED: // Don’t do anything if the palette does not exist, or if // this is the window that changed the palette. if((hPalette != NULL) && ((HWND)wParam != hWnd)) { // Select the palette into the device context SelectPalette(hDC,hPalette,FALSE); // Map entries to system palette RealizePalette(hDC); // Remap the current colors to the newly realized palette UpdateColors(hDC); return 0; } break; Another message sent by Windows for palette realization is WM_PALETTECHANGED. This message is sent to windows that can realize their palette but may not have the current focus. When this message is sent, you must also check the value of wParam. If wParam contains the handle to the current window receiving the message, then WM_QUERYNEWPALETTE has already been processed, and the palette does not need to be realized again. Note also in Listing 8-2 that the value of hPalette is checked against NULL before either of these palette-realization messages is processed. If the application is not running in 8-bit color mode, then no palette needs to be created or realized by these functions. Structuring your code in this way makes it useful for displays that don t use palettes as well as those that do. Creating a Palette Unfortunately, palette considerations are a necessary evil if your application is to run on the 8-bit hardware that s still in use in some environments. So what do you do if your code is executing on a machine that only supports 256 colors? For image reproduction, we recommend selecting a range of colors that closely match the original colors. For OpenGL rendering under most circumstances, however, you want the widest possible range of colors for general-purpose use. The trick is to select the palette colors so that they re evenly distributed throughout the color cube. Then, whenever a color is specified that is not already in the palette, Windows will select the nearest color in the color cube. As mentioned earlier, this is not ideal for some applications, but for OpenGL rendered scenes it is the best we can do. Unless there is substantial texture mapping in the scene with a wide variety of colors, results are usually acceptable.
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply