---
name: "glCopyColorTable"
section: "3x"
platform: "linux"
package: "xlibmesa-gl-dev"
version: "4.3.0.dfsg.1-14sarge7"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/glCopyColorTable"
---

# glCopyColorTable(3x)

copy pixels into a color table

## NAME

**glCopyColorTable** - copy pixels into a color table

## C SPECIFICATION

void **glCopyColorTable**( GLenum *target*,

```
	GLenum internalformat,
	GLint x,
	GLint y,
	GLsizei width )
```

delim $$

## PARAMETERS

- *target*

  The color table target. Must be **GL\_COLOR\_TABLE**, **GL\_POST\_CONVOLUTION\_COLOR\_TABLE**, or **GL\_POST\_COLOR\_MATRIX\_COLOR\_TABLE**.

- *internalformat*

  The internal storage  of the texture image. Must be one of the following symbolic constants: **GL\_ALPHA**, **GL\_ALPHA4**, **GL\_ALPHA8**, **GL\_ALPHA12**, **GL\_ALPHA16**, **GL\_LUMINANCE**, **GL\_LUMINANCE4**, **GL\_LUMINANCE8**, **GL\_LUMINANCE12**, **GL\_LUMINANCE16**, **GL\_LUMINANCE\_ALPHA**, **GL\_LUMINANCE4\_ALPHA4**, **GL\_LUMINANCE6\_ALPHA2**, **GL\_LUMINANCE8\_ALPHA8**, **GL\_LUMINANCE12\_ALPHA4**, **GL\_LUMINANCE12\_ALPHA12**, **GL\_LUMINANCE16\_ALPHA16**, **GL\_INTENSITY**, **GL\_INTENSITY4**, **GL\_INTENSITY8**, **GL\_INTENSITY12**, **GL\_INTENSITY16**, **GL\_R3\_G3\_B2**, **GL\_RGB**, **GL\_RGB4**, **GL\_RGB5**, **GL\_RGB8**, **GL\_RGB10**, **GL\_RGB12**, **GL\_RGB16**, **GL\_RGBA**, **GL\_RGBA2**, **GL\_RGBA4**, **GL\_RGB5\_A1**, **GL\_RGBA8**, **GL\_RGB10\_A2**, **GL\_RGBA12**, **GL\_RGBA16**.

- *x*

  The x coordinate of the lower-left corner of the pixel rectangle to be transferred to the color table.

- *y*

  The y coordinate of the lower-left corner of the pixel rectangle to be transferred to the color table.

- *width*

  The width of the pixel rectangle.

## DESCRIPTION

**glCopyColorTable** loads a color table with pixels from the current **GL\_READ\_BUFFER** (rather than from main memory, as is the case for **glColorTable**).

The screen-aligned pixel rectangle with lower-left corner at (*x*, *y*) having width *width* and height 1 is loaded into the color table. If any pixels within this region are outside the window that is associated with the GL context, the values obtained for those pixels are undefined.

The pixels in the rectangle are processed just as if **glReadPixels** were called, with *internalformat* set to RGBA,  but processing stops after the final conversion to RGBA.

The four scale parameters and the four bias parameters that are defined for the table are then used to scale and bias the R, G, B, and A components of each pixel. The scale and bias parameters are set by calling **glColorTableParameter**.

Next, the R, G, B, and A values are clamped to the range \[0,1\]. Each pixel is then converted to the internal  specified by *internalformat*. This conversion simply maps the component values of the pixel (R, G, B, and A) to the values included in the internal  (red, green, blue, alpha, luminance, and intensity).  The mapping is as follows:

| | | | | | | |
| --- | --- | --- | --- | --- | --- | --- |
| **Internal Format** | **Red** | **Green** | **Blue** | **Alpha** | **Luminance** | **Intensity** |
| **GL\_ALPHA** |  |  |  | A |
| **GL\_LUMINANCE** |  |  |  |  | R |
| **GL\_LUMINANCE\_ALPHA** |  |  |  | A | R |
| **GL\_INTENSITY** |  |  |  |  |  | R |
| **GL\_RGB** | R | G | B |
| **GL\_RGBA** | R | G | B | A |

Finally, the red, green, blue, alpha, luminance, and/or intensity components of the resulting pixels are stored in the color table. They form a one-dimensional table with indices in the range \[0, *width* - 1\].

## NOTES

**glCopyColorTable** is available only if **GL\_ARB\_imaging** is returned from calling **glGetString** with an argument of **GL\_EXTENSIONS**.

## ERRORS

**GL\_INVALID\_ENUM** is generated when *target* is not one of the allowable values.

**GL\_INVALID\_VALUE** is generated if *width* is less than zero.

**GL\_INVALID\_VALUE** is generated if *internalformat* is not one of the allowable values.

**GL\_TABLE\_TOO\_LARGE** is generated if the requested color table is too large to be supported by the implementation.

**GL\_INVALID\_OPERATION** is generated if **glCopyColorTable** is executed between the execution of **glBegin** and the corresponding execution of **glEnd**.

## ASSOCIATED GETS

**glGetColorTable**, **glGetColorTableParameter**

## SEE ALSO

**glColorTable(3G)**, **glColorTableParameter(3G)**, **glReadPixels(3G)**
