Next: 3.2 Double Buffering Up: 3 Advanced Xlib and Previous: 3 Advanced Xlib and

3.1 Colormaps

Already a method has been presented for sharing colormaps using the ICCCM conventions. Most OpenGL programs do not use the default visual and therefore cannot use the default colormap. Sharing colormaps is therefore important for OpenGL programs to minimize the amount of colormaps X servers will need to create.

Often OpenGL programs require more than one colormap. A typical OpenGL program may do OpenGL rendering in a subwindow but most of the program's user interface is implemented using normal X 2D rendering. If the OpenGL window is 24 bits deep, it would be expensive to require all the user interface windows also to be 24 bits deep. Among other things, pixmaps for the user interface windows would need to be 32 bits per pixel instead of the typical 8 bits per pixel. So the program may use the server's (probably default) 8 bit PseudoColor visual for its user interface but use a 24 bit TrueColor visual for its OpenGL subwindow. Multiple visuals demand multiple colormaps. Many other situations may arise when an OpenGL program needs multiple colormaps within a single top-level window hierarchy.

Normally window managers assume the colormap that a top-level window and all its subwindows need is the colormap used by the top-level window. A window manager automatically notices the colormap of the top-level window and tries to ensure that that colormap is installed when the window is being interacted with.

With multiple colormaps used inside a single top-level window, the window manager needs to be informed of the other colormaps being used. The Xlib routine XSetWMColormapWindows can be used to place a standard property on your top-level window to indicate all the colormaps used by the top-level window and its descendants.

Be careful about using multiple colormaps. It is possible a server will not have enough colormap resources to support the set of visuals and their associated colormaps that you desire. Unfortunately, there is no standard way to determine what sets of visuals and colormaps can be simultaneously installed when multiple visuals are supported. Xlib provides two calls, XMaxCmapsOfScreen and XMinCmapsOfScreen, but these do not express hardware conflicts between visuals.

Here are some guidelines:

Hopefully multiple hardware colormaps will become more prevalent and perhaps a standard mechanism to detect colormap and visual conflicts will become available.



Next: 3.2 Double Buffering Up: 3 Advanced Xlib and Previous: 3 Advanced Xlib and


mjk@asd.sgi.com
Wed Oct 19 18:11:46 PDT 1994