Export (0) Print
Expand All
Expand Minimize

glColorTableEXT function

Applies to: desktop apps only

The glColorTableEXT function specifies the format and size of a palette for targeted paletted textures.

Syntax

void WINAPI glColorTableEXT(
  GLenum target,
  GLenum internalFormat,
  GLsizei width,
  GLenum format,
  GLenum type,
  const GLvoid *data
);

Parameters

target

The target texture that is to have its palette changed. Must be TEXTURE_1D, TEXTURE_2D, PROXY_TEXTURE_1D, or PROXY_TEXTURE_2D.

internalFormat

The internal format and resolution of the palette. This parameter can assume one of the following symbolic values.

ConstantBase FormatR BitsG BitsB BitsA Bits
GL_R3_G3_B2GL_RGB332 
GL_RGB4GL_RGB444 
GL_RGB5GL_RGB555 
GL_RGB8GL_RGB888 
GL_RGB10GL_RGB101010 
GL_RGB12GL_RGB121212 
GL_RGB16GL_RGB161616 
GL_RGBA2GL_RGBA2222
GL_RGBA4GL_RGBA4444
GL_RGB5_A1GL_RGBA5551
GL_RGBA8GL_RGBA8888
GL_RG10_A2GL_RGBA1010102
GL_RGB12GL_RGBA12121212
GL_RGBA16GL_RGBA16161616

 

width

The size of the palette. Must be 2n ≤ 1 for some integer n.

format

The format of the pixel data. The following symbolic constants are accepted.

ValueMeaning
GL_RGBA

Each pixel is a group of four components in this order: red, green, blue, alpha. The RGBA format is determined in this way:

  1. The glColorTableEXT function converts floating-point values directly to an internal format with unspecified precision. Signed integer values are mapped linearly to the internal format such that the most positive representable integer value maps to 1.0, and the most negative representable integer value maps to -1.0. Unsigned integer data is mapped similarly: the largest integer value maps to 1.0, and zero maps to 0.0.
  2. The glColorTableEXT function multiplies the resulting color values by GL_c_SCALE and adds them to GL_c_BIAS, where c is RED, GREEN, BLUE, and ALPHA for the respective color components. The results are clamped to the range [0,1].
  3. If GL_MAP_COLOR is TRUE, glColorTableEXT scales each color component by the size of lookup table GL_PIXEL_MAP_c_TO_c, then replaces the component by the value that it references in that table; c is R, G, B, or A, respectively.
  4. The glColorTableEXT function converts the resulting RGBA colors to fragments by attaching the current raster position z-coordinate and texture coordinates to each pixel, then assigning x and y window coordinates to the nth fragment such that

    xn = xr + n mod width

    yn = yr +n / width

    where (xr , yr ) is the current raster position.

  5. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. The glColorTableEXT function applies texture mapping, fog, and all the fragment operations before writing the fragments to the framebuffer.
GL_RED

Each pixel is a single red component.

The glColorTableEXT function converts this component to the internal format in the same way that the red component of an RGBA pixel is, then converts it to an RGBA pixel with green and blue set to 0.0, and alpha set to 1.0. After this conversion, the pixel is treated just as if it had been read as an RGBA pixel.

GL_GREEN

Each pixel is a single green component.

The glColorTableEXT function converts this component to the internal format in the same way that the green component of an RGBA pixel is, and then converts it to an RGBA pixel with red and blue set to 0.0, and alpha set to 1.0. After this conversion, the pixel is treated just as if it had been read as an RGBA pixel.

GL_BLUE

Each pixel is a single blue component.

The glColorTableEXT function converts this component to the internal format in the same way that the blue component of an RGBA pixel is, and then converts it to an RGBA pixel with red and green set to 0.0, and alpha set to 1.0. After this conversion, the pixel is treated just as if it had been read as an RGBA pixel.

GL_ALPHA

Each pixel is a single alpha component.

The glColorTableEXT function converts this component to the internal format in the same way that the alpha component of an RGBA pixel is, and then converts it to an RGBA pixel with red, green, and blue set to 0.0. After this conversion, the pixel is treated just as if it had been read as an RGBA pixel.

GL_RGB

Each pixel is a group of three components in this order: red, green, blue.

The glColorTableEXT function converts each component to the internal format in the same way that the red, green, and blue components of an RGBA pixel are. The color triple is converted to an RGBA pixel with alpha set to 1.0. After this conversion, the pixel is treated just as if it had been read as an RGBA pixel.

GL_BGR_EXT

Each pixel is a group of three components in this order: blue, green, red.

GL_BGR_EXT provides a format that matches the memory layout of Windows device-independent bitmaps (DIBs). Thus your applications can use the same data with Windows function calls and OpenGL pixel function calls.

GL_BGRA_EXT

Each pixel is a group of four components in this order: blue, green, red, alpha.

GL_BGRA_EXT provides a format that matches the memory layout of Windows device-independent bitmaps (DIBs). Thus your applications can use the same data with Windows function calls and OpenGL pixel function calls.

 

type

The data type for data. The following symbolic constants are accepted: GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, and GL_FLOAT.

The following table summarizes the meaning of the valid constants for the type parameter.

ValueMeaning
GL_UNSIGNED_BYTE

Unsigned 8-bit integer

GL_BYTE

Signed 8-bit integer

GL_UNSIGNED_SHORT

Unsigned 16-bit integer

GL_SHORT

Signed 16-bit integer

GL_UNSIGNED_INT

Unsigned 32-bit integer

GL_INT

32-bit integer

GL_FLOAT

Single-precision floating-point value

 

data

A pointer to the paletted texture data. The data is treated as single pixels of a 1-D texture palette entry for a palette entry.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_VALUE

width was an invalid integer.

GL_INVALID_ENUM

target, internalFormat, format, or type was not an accepted value.

GL_INVALID_OPERATION

The function was called between a call to glBegin and the corresponding call to glEnd.

Remarks

Paletted textures are defined with a palette of colors and a set of image data that is composed of indexes to color entries of a palette (a color table).

The glColorTableEXT function specifies the texture palette of a targeted texture. It takes the data from memory and converts the data as if each palette entry is a single pixel of a 1-D texture. The glColorTableEXT function unpacks and converts the data and translates it into an internal format that matches the given format as closely as possible.

If a palette's width is greater than the range of the color indexes in the texture data, some of the palette entries are unused. If a palette's width is less than the range of the color indexes in the texture data, the most significant bits of the texture data are ignored and only the appropriate number of bits in the index are used when accessing the palette. When you specify a proxy target using PROXY_TEXTURE_1D or PROXY_TEXTURE_2D, the palette of the proxy texture is resized and its parameters are set but no data is transferred or accessed.

When the target parameter is GL_PROXY_TEXTURE_1D or GL_PROXY_TEXTURE_2D, and the implementation does not support the values specified for either format or width, glColorTableEXT can fail to create the requested color table. In this case, the color table is empty and all parameters retrieved will be zero. You can determine whether OpenGL supports a particular color table format and size by calling glColorTableEXT with a proxy target, and then calling glGetColorTableParameterivEXT or glGetColorTableParameterfvEXT to determine whether the width parameter matches that set by glColorTableEXT. If the retrieved width is zero, the color table request by glColorTable failed. If the retrieved width is not zero, you can call glColorTable with the real target with TEXTURE_1D or TEXTURE_2D to set the color table.

Note  The glColorTableEXT function is an extension function that is not part of the standard OpenGL library but is part of the GL_EXT_paletted_texture extension. To check whether your implementation of OpenGL supports glColorTableEXT, call glGetString(GL_EXTENSIONS). If it returns GL_EXT_paletted_texture, glColorTableEXT is supported. To obtain the function address of an extension function, call wglGetProcAddress.

To retrieve the actual color table data specified by the glColorTableEXT function, call glGetColorTableEXT. To retrieve the parameters, such as width and format, of the color table specified by the glColorTableEXT function, call the glGetColorTableParameterivEXT or glGetColorTableParameterfvEXT function.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Gl.h

See also

glBegin
glColorSubTableEXT
glEnd
glGetColorTableEXT
glGetColorTableParameterfvEXT
glGetColorTableParameterivEXT
wglGetProcAddress

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft