1In This Chapter
You will learn about:
2Specifying Colors
A color consists of three or four color components: red, green, blue, and optionally, alpha. The color component values should be clamped to the range [0..255] where 0 is black and 255 is maximum intensity.
The color components are packed together into a word to form a color. Glide supports four different color byte orderings, defined in the enumerated type GrColorFormat_t (see Figure Getting Started.1 for a pictorial representation). Color byte ordering determines how linear frame buffer writes and color arguments are interpreted and is established in the call to grSstWinOpen() when the Glide and Voodoo Graphics systems are initialized (see Chapter Chapter 3. ).
The GrColor_t type definition represents a packed color value and is used in routines that set a constant color: grBufferClear() (see Chapter Chapter 3. ), grConstantColorValue() (described below), grFogColorValue() and grChromakeyValue() (both described in Chapter Chapter 8. ).
void grConstantColorValue( GrColor_t color )
Glide refers to a global constant color when performing flat-shaded primitive rendering, set with grConstantColorValue(). The default value is 0xFFFFFFFF.
Vertex colors are specified in the GrVertex structure as individual color components, since the Voodoo Graphics system will iterate and compute slopes for each color individually.
3Dithering
The Voodoo Graphics hardware represents color internally as 32-bit quadruplets in a format specified by the color format argument passed to grSstWinOpen() (see Chapter Chapter 3. ). This color is eventually dithered to 16-bit RGB for storage in the frame buffer, then expanded and (optionally) filtered up to 24-bits for final display. From an application’s perspective, the 32-to-16-bit RGB dithering operation is transparent.
Dithering is a technique for increasing the perceived range of colors in an image by applying a pattern to surrounding pixels to modify their color values. When viewed from a distance, these colors appear to blend into an intermediate color that can’t be represented directly. Dithering is similar to the half-toning used in black and white publications to produce shades of gray.
void grDitherMode( GrDitherMode_t mode )
grDitherMode() selects the form of dithering the Voodoo Graphics subsystem uses when converting 24-bit RGB values to the 16-bit RGB color buffer format. Valid values are GR_DITHER_DISABLE, GR_DITHER_2x2, and GR_DITHER_4x4. GR_DITHER_DISABLE forces a simple truncation that may result in noticeable banding. GR_DITHER_2x2 uses a 2x2 ordered dither matrix, and GR_DITHER_4x4 uses a 4x4 ordered dither matrix.
The default dithering mode is GR_DITHER_4x4.
Share with your friends: |