| United States-English |
|
|
|
![]() |
HP PEX Implementation and Programming Supplement: HP9000 Series 700 Color Workstations > Chapter 3 Running HP PEXlib Programs Setting and Using Environment Variables |
|
This section provides instructions for setting and controlling the environment variables that you can use to configure the PEXlib client. To assure interoperability, your program should look for the existence of environment variables, since these variables are implementation-dependent, in order to use them as program parameters. If these do not exist, then the program uses default values. Environment variables supported on HP workstations are summarized in the following table. Additional information you'll need for implementing them is provided either later in this chapter or in Chapter 6 “Writing HP PEXlib Programs ”, as appropriate. Table 3-3 Environment Variable Summary
There are two ways to set environment variables. The choice depends on whether you are using HP CDE or if you are simply using the X environment. Both methods are illustrated using the HP_ENABLE_TRANSPARENT_MODE environment variable:
Color resources are set using color names either from the X11 color database rgb.txt, or using the syntax #RedGreenBlue where Red, Green, and Blue are hexadecimal numbers containing 1, 2, 3, or 4 digits (that is, #rgb, #rrggbb, #rrrgggbbb, and #rrrrggggbbbb are all legal syntaxes). These hexadecimal numbers indicate the amount used of that primary color. There must be the same number of digits for each of the primary colors. For example, color names from rgb.txt or a color specified by one of these can take the following form (where r, g, and b are hexadecimal digits):
To set an environment variable for color, you may use this syntax:
Colors are set, using the syntax shown above, for these HP environment variables:
The default colors are echoed for primitives in a newly-created Renderer. Note that echoing in HP PEX is done using "exclusive-or" drawing mode. This means that the actual echo color rendered will vary in different image locations based upon the frame buffer contents prior to rendering. More information about application resources, including color, is found in the book Using the X Window System. When using the PEX Protocol Method of connecting to the server, (that is, you have set HPPEX_CLIENT_PROTOCOL to PEX), you must reset the following environment variables, if you wish to use them, before the X server is started on the PEX server's system for the variables to have an effect:
Setting these variables before starting the client process will not affect the PEX server which, ultimately, does the final rendering. The environment variable HPPEX_DHA_COMPLIANCE_MODE allows users to specify whether HP PEXlib strictly adheres to the standard, or to maximize HP PEX's performance, allowing some minor behavioral differences. In most PEXlib applications, these differences should be acceptable and preferable for the performance edge. For this reason this is the default behavior; that is, the variable is not set. If your application cannot tolerate any differences from the standard, then set this variable. It is also recommended this variable be set during development of an application to enable more robust error checking. Because users must explicitly set HPPEX_DHA_COMPLIANCE_MODE, this default behavior will exhibit minor differences from the standard. Here are the differences from the standard when HPPEX_DHA_COMPLIANCE_MODE is off:
Because invalid data can cause programs to fail, Hewlett-Packard suggests the compliance mode variable be set during development of the application, and unset once the application is defect-free. The precise performance differences with the mode set and unset vary with the application. The application documentation should specify whether or not this variable should be set. When the variable HPPEX_DHA_AUTO_COLOR_APPROX is not set, HP PEX checks the values in a color approximation table entry and reports an error if any of the values do not match what is supported on the particular device and visual. If the variable is set to any value, HP PEX recognizes unsupported values as the color approximation entry values are set. But rather than reporting an error, it creates and initializes a new X color map with a supported content for any window on which the invalid color approximation entry is used at the time it is installed. While this is not standard PEX behavior, the advantage is that it allows some clients to run that would otherwise fail.
On graphics devices with only one hardware colormap, PEX applications may experience "color flashing." Color flashing is the condition where colors displayed on the workstation screen change as the focus moves from X window to X window and where the PEX image looks correct only when the focus is in its window. This is common on low-end graphics devices because most PEX applications are demanding in their color usage, more demanding than many other X clients and window managers. Therefore, the PEX default color sampling requires a different colormap setup than many X clients and window managers. When the graphics device only supports one hardware colormap, both colormaps cannot be installed at the same time, and the switch from one colormap to another in hardware causes color flashing. HP offers a method for avoiding color flashing on low-end graphics devices through the use of the environment variable SB_X_SHARED_CMAP. The use of this environment variable is explained in further detail below. However, you need to be aware that this may result in anomalous color behavior with some color-demanding X clients and window managers such as HP CDE. (An example of aberrant color behavior would be the minute hand on the clock in the HP CDE front panel leaving behind a different color as it moves around the face of the clock.) If you are using a low-end graphics device with only one hardware colormap, you can avoid color flashing through the use of the SB_X_SHARED_CMAP environment variable. This is the best choice if you do not use color-demanding X clients and window managers such as HP CDE in "High Color" mode (the default HP CDE color mode). If you must avoid aberrant color behavior by color-demanding X clients, then this method is not available to you. In general, if you attempt to share X colormaps among color-demanding X and PEX applications on a low-end graphics device, you may experience unexpected color behavior. The setting of the SB_X_SHARED_CMAP environment variable determines the supported PEXColorSpace color approximation entry on the display. This environment variable has effect only on older simple HP displays that only support depth 8 visuals and exerts its effect at the time that the X/PEX server is started. (Changing the value after the server is running has no effect, except when X protocol mode is being used with a non-HP server. In this case, the local value of the variable at the time the PEX application is started controls the color approximation support.) SB_X_SHARED_CMAP is especially important if you have PEX applications that need to share a colormap (perhaps the default colormap) with other X clients. In such a case, it is common for the X clients and window managers to be using pixel values in the low end of the colormap, for X rendering and for borders and backgrounds. On all of the single-visual devices, HP PEX supports a colormap in which the lowest forty cells are available for X clients, and the upper 216 cells are set up in an RGB color space sampling that HP PEX supports via PEXColorSpace approximation. This colormap configuration is often called a "6|6|6" colormap, because the color sampling includes six levels each of red, green, and blue. The 6|6|6 default colormap setup and PEX color approximation support are enabled by setting SB_X_SHARED_CMAP to any value before the X/PEX server is started. If SB_X_SHARED_CMAP is not set, HP PEX supports a color sampling using 8 values of red, 8 of green, and 4 of blue. This colormap configuration is called "8|8|4." (It is also sometimes called "3:3:2", for the number of planes allocated to each of red, green, and blue. Note that "|" is used to delimit color levels and ":" is used to delimit frame buffer planes.) Since 8|8|4 mode consumes all 256 cells in the colormap, a PEX application must use a colormap other than the default. Regardless of which protocol method of connecting to the server is used, you must reset the environment variable, SB_X_SHARED_CMAP, if you wish to use it, before the X server is started on the PEX server's system for the variable to have an effect. On devices with only one hardware colormap, both the 6|6|6 colormap being used by the other clients, and the 8|8|4 colormap being used by PEX, cannot be installed at the same time. This results in "color flashing", since the PEX image will not look correct except when the 8|8|4 colormap is installed.
The CRX device (only) exhibits one exception to standard X/PEX color support. For best performance, it requires a color sampling (either 6|6|6 or 8|8|4) in the colormap that contains the same number and values of cells as the other single-visual devices, but the cells are not in the "canonical" order described by X standard colormap properties or PEX color approximation entries. HP provides a program, xhpcmap, to transform a canonical color sampling into the required "shuffled" setup. If your PEX applications all use this utility or equivalent code, you can set SB_X_SHARED_CMAP to "True" as described above, and obtain the best performance possible on the CRX. If, however, you have applications that do not incorporate code to set up the "shuffled" colormap, or there are other reasons why the special colormap is unacceptable, you can set SB_X_SHARED_CMAP to the special value XA_RGB_DEFAULT before starting the X/PEX server. HP PEX will render correctly using a canonical 6|6|6 colormap, but rendering performance on CRX may be noticeably impacted. The only mechanism to cause rendering to a canonical 8|8|4 colormap on CRX is to set HPPEX_CLIENT_PROTOCOL to "X" though, again, performance may be affected. In order to provide higher-quality shaded images on low-cost 3D graphics systems like the Model 712, as well as the HCRX-8 devices, you can take advantage of a new feature called color recovery. Color recovery provides better pictures on low-cost workstations than are possible using only dithering by attempting to eliminate the apparent graininess caused by dithering. Use of the color recovery feature attaches a different colormap to the X window than the application originally attaches. The colormap substitution occurs on the first PEXBeginRendering or other similar entrypoint that binds the renderer to the window. However, since it only occurs in TrueColor visuals, color flashing due to this change should not be objectionable. Applications that attempt to free the colormap they created will succeed; it is recommended that they not assume they can free whatever colormap is currently attached to the window, since the substitution may have occurred and they will get a permissions error. Color recovery requires a different dither cell size when rendering shaded polygons and a digital filter is used when displaying the contents of the frame buffer to the screen. For this reason, color recovery can occasionally produce undesirable artifacts in the image. Some applications that read or write PEX images as raster images may be affected by the different dither cell. To disable color recovery, you'll need to set and export the environment variable HP_DISABLE_COLOR_RECOVERY in the environment in which the X/PEX server is started before running your application. This disables the colormap substitution and color recovery. However, if this environment variable is not set in the server's environment, but is set in the DHA client's environment, color recovery is disabled for the client only. The color recovery colormap is a read-only colormap. Attempts to change it are ignored and errors are not reported. TrueColor visuals are supported with 9.05 release and later releases of HP-UX. Note that applications created prior to the 9.03 release of HP-UX may exercise new paths through their source when using this visual. To avoid compatibility problems, an environment variable has been included in X Windows for the HP-UX 9.03 and 9.05 release only. The name of this environment variable is:
The existence (not the value) of the HP_SUPPRESS_TRUECOLOR_VISUAL environment variable before starting the X11 server disables the TrueColor visual. If you set this environment variable after starting X11 server, it will be ignored. To set the HP_SUPPRESS_TRUECOLOR_VISUAL environment variable before the X11 server is started, use one of the methods given below. If you are using x11start, make sure you have the environment variable HP_SUPPRESS_TRUECOLOR_VISUAL set before you execute x11start:
The best way to do this is to include it in your $HOME/.profile. To unset the environment variable, type:
and restart the X11 server. If you are using HP CDE (Common Desktop Environment) add the following line to your Xconfig file:
The Xconfig file may contain commented out entries for some of the more popular resources, including "environment." Simply find the line containing "environment," add the appropriate value, and uncomment the line. To unset the environment variable, remove this line:
from your Xconfig file and restart the X11 server. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||