Next | Prev | Up | Top | Contents | Index

The Color Matrix Extension

The color matrix extension, SGI_color_matrix, lets you transform the colors in the imaging pipeline with a 4 x 4 matrix. You can use the color matrix to reassign and duplicate color components and to implement simple color-space conversions.

This extension adds a 4 x 4 matrix stack to the pixel transfer path. The matrix operates on RGBA pixel groups, multiplying the 4 x 4 color matrix on top of the stack with the components of each pixel. The stack is manipulated using the OpenGL 1.0 matrix manipulation functions: glPushMatrix(), glPopMatrix(), glLoadIdentity(), glLoadMatrix(), and so on. All standard transformations, for example glRotate() or glTranslate(), also apply to the color matrix.

Below is an example of a color matrix that swaps BGR pixels to form RGB pixels:

GLfloat colorMat[16] = {0.0, 0.0, 1.0, 0.0,

0.0, 1.0, 0.0, 0.0,

1.0, 0.0, 0.0, 0.0,

0.0, 0.0, 0.0, 0.0 };

glMatrixMode(GL_COLOR);
glPushMatrix();
glLoadMatrixf(colorMat);
After the matrix multiplication, each resulting color component is scaled and biased by the appropriate user-defined scale and bias values. Color matrix multiplication follows convolution (and convolution scale and bias).

To set scale and bias values to be applied after the color matrix, call glPixelTransfer*() with the following values for pname:



Next | Prev | Up | Top | Contents | Index