OpenGL Super (Medical web site) Bible! Page 291 // Window is
OpenGL Super Bible! Page 291 // Window is being destroyed, cleanup case WM_DESTROY: // Deselect the current rendering context and delete it wglMakeCurrent(hDC,NULL); wglDeleteContext(hRC); // If a palette was created, destroy it here if(hPalette != NULL) DeleteObject(hPalette); // Tell the application to terminate after the window // is gone. PostQuitMessage(0); break; Some Restrictions Apply Not all of your 256 palette entries will actually be mapped to the system palette. Windows reserves 20 entries for static system colors that include the standard 16 VGA/EGA colors. This protects the standard windows components (title bars, buttons, etc.) from alteration whenever an application changes the system palette. When your application realizes its palette, these 20 colors will not be overwritten. Fortunately, some of these colors already exist or are closely matched in the 3-3-2 palette. Those that don t are closely enough matched that you shouldn t be able to tell the difference. Color Index Mode OpenGL also supports the alternative color index mode. In this mode, you specify a color for drawing operations by specifying an index into an array of colors, rather than as an RGB triplet. You cannot use color index mode and RGBA color mode together. This means if you use color index mode on a true-color device (or near true-color, such as a 16- bit color card), you won t have access to all the available colors. Under some implementations, the color index palette can be up to 4,096 entries long. The Microsoft implementation however, only supports 256 entries. You can use color index mode to do contour mapping in which some function of the surface returns an index into the palette. It is somewhat faster than RGBA, and the limitations of the 3-3-2 palette do not exist. For example, if you need 200 shades of gray, you can have them. However, some of the lighting effects discussed in the next chapter are not available under color index mode either. Why Use Color Index Mode? There are really very few good reasons to use color index mode. Typically, this mode is used to get more control over the palette. You can also do palette animation, but only on
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.