Next | Prev | Up | Top | Contents | Index

Specifying a Color Table

To specify a color lookup table, call glColorTableSGI():

void glColorTableSGI( GLenum target, GLenum internalformat, GLsizei width, 
                      GLenum format, GLenum type,const GLvoid *table) 
If no error results from the execution of glColorTableSGI(), the following events occur:

  1. The specified color lookup table is defined to have width entries, each with the specified internal format. The entries are indexed as zero through N-1, where N is the width of the table. The values in the previous color lookup table, if any, are lost. The new values are specified by the contents of the one-dimensional image that table points to, with format as the memory format and type as the data type.

  2. The specified image is extracted from memory and processed as if glDrawPixels() were called, stopping just before the application of pixel transfer modes (see the illustration "Drawing Pixels with glDrawPixels*()" in Chapter 8, "Bitmaps, Fonts, and Images," of the OpenGL Programming Guide).

  3. The R, G, B, and A components of each pixel are first scaled by the four GL_COLOR_TABLE_SCALE_SGI parameters, then biased by the four GL_COLOR_TABLE_BIAS_SGI parameters and clamped to [0,1].

    The scale and bias parameters are themselves specified by calling glColorTableParameterivSGI() or glColorTableParameterfvSGI():

  4. Each pixel is then converted to have the specified internal format. This conversion maps the component values of the pixel (R, G, B, and A) to the values included in the internal format (red, green, blue, alpha, luminance, and intensity).
The new lookup tables are treated as 1-dimensional images with internal formats, like texture images and convolution filter images. As a result, the new tables can operate on a subset of the components of passing pixel groups. For example, a table with internal format GL_ALPHA modifies only the A component of each pixel group, leaving the R, G, and B components unmodified.


Next | Prev | Up | Top | Contents | Index