next up previous contents index
Next: 2.13.1 Lighting Up: 2 OpenGL Operation Previous: 2.12 Current Raster Position

2.13 Colors and Coloring


Figure 2.8: Processing of colors. n is the number of bits in a color index; m is the number of bits an R, G, B, or A component. See Table 2.6 for the interpretation of k.

Figure 2.8 diagrams the processing of colors before rasterization. Incoming colors arrive in one of several formats. Table 2.6 summarizes the conversions that take place on R, G, B, and A components depending on which version of the Color  command was invoked to specify the components. As a result of limited precision, some converted values will not be represented exactly. In color index mode, a single-valued color index is not mapped.

Table 2.6: Component conversions. Color, normal, and depth components, (c), are converted to an internal floating-point representation, (f), using the equations in this table. All arithmetic is done in the internal floating point format. These conversions apply to components specified as parameters to GL commands and to components in pixel data. The equations remain the same even if the implemented ranges of the GL data types are greater than the minimum required ranges. (Refer to table 2.2)

Next, lighting, if enabled, produces a color. If lighting is disabled, the current color is used in further processing. After lighting, RGBA colors are clamped to the range . A color index is converted to fixed-point and then its integer portion is masked (see section 2.13.6). After clamping or masking, a primitive may be flatshaded, indicating that all vertices of the primitive are to have the same color. Finally, if a primitive is clipped, then colors (and texture coordinates) must be computed at the vertices introduced or modified by clipping.

David Blythe
Sat Mar 29 02:23:21 PST 1997