glCopyTexImage2D

[New - Windows 95, OEM Service Release 2]

The glCopyTexImage2D function copies pixels from the frame buffer into a two-dimensional texture image.

void glCopyTexImage2D(

    GLenum target,

 

    GLint level,

 

    GLenum internalFormat,

 

    GLint x,

 

    GLint y,

 

    GLsizei width,

 

    GLsizei height,

 

    GLint border

 

   );

 

 

Parameters

target

The target to which the image data will be changed. Must have the value GL_TEXTURE_2D.

level

The level-of-detail number. Level 0 is the base image. Level n is the nth mipmap reduction image.

internalFormat

The internal format and resolution of the texture data. The values 1, 2, 3, and 4 are not accepted for internalFormat. The parameter can assume one of the following symbolic values:

Constant

Base Format

R Bits

G Bits

B Bits

A Bits

L Bits

I Bits

ALPHA

 

 

 

 

 

 

 

ALPHA4

ALPHA

 

 

 

4

 

 

ALPHA8

ALPHA

 

 

 

8

 

 

ALPHA12

ALPHA

 

 

 

12

 

 

ALPHA16

ALPHA

 

 

 

16

 

 

LUMINANCE

 

 

 

 

 

 

 

LUMINANCE4

LUMINANCE

 

 

 

 

4

 

LUMINANCE8

LUMINANCE

 

 

 

 

8

 

LUMINANCE12

LUMINANCE

 

 

 

 

12

 

LUMINANCE16

LUMINANCE

 

 

 

 

16

 

LUMINANCE_ALPHA

 

 

 

 

 

 

 

LUMINANCE4_ALPHA4

LUMINANCE_ALPHA

 

 

 

4

4

 

LUMINANCE6_ALPHA2

LUMINANCE_ALPHA

 

 

 

2

6

 

LUMINANCE8_ALPHA8

LUMINANCE_ALPHA

 

 

 

8

8

 

LUMINANCE12_ALPHA4

LUMINANCE_ALPHA

 

 

 

4

12

 

LUMINANCE12_ALPHA12

LUMINANCE_ALPHA

 

 

 

12

12

 

LUMINANCE16_ALPHA16

LUMINANCE_ALPHA

 

 

 

16

16

 

INTENSITY

 

 

 

 

 

 

 

INTENSITY4

INTENSITY

 

 

 

 

 

4

INTENSITY8

INTENSITY

 

 

 

 

 

8

INTENSITY12

INTENSITY

 

 

 

 

 

12

INTENSITY16

INTENSITY

 

 

 

 

 

16

GL_RGB

 

 

 

 

 

 

 

GL_R3_G3_B2

GL_RGB

3

3

2

 

 

 

GL_RGB4

GL_RGB

4

4

4

 

 

 

GL_RGB5

GL_RGB

5

5

5

 

 

 

GL_RGB8

GL_RGB

8

8

8

 

 

 

GL_RGB10

GL_RGB

10

10

10

 

 

 

GL_RGB12

GL_RGB

12

12

12

 

 

 

GL_RGB16

GL_RGB

16

16

16

 

 

 

GL_RGBA

 

 

 

 

 

 

 

GL_RGBA2

GL_RGBA

2

2

2

2

 

 

GL_RGBA4

GL_RGBA

4

4

4

4

 

 

GL_RGB5_A1

GL_RGBA

5

5

5

1

 

 

GL_RGBA8

GL_RGBA

8

8

8

8

 

 

GL_RGB10_A2

GL_RGBA

10

10

10

2

 

 

GL_RGBA12

GL_RGBA

12

12

12

12

 

 

GL_RGBA16

GL_RGBA

16

16

16

16

 

 

 

x, y

The window coordinates of the lower-left corner of the rectangular region of pixels to be copied.

width

The width of the texture image. Must be 2^n + 2 * border for some integer n.

height

The height of the texture image. Must be 2^n + 2 * border for some integer n.

border

The width of the border. Must be either zero or 1.

 

Remarks

The glCopyTexImage2D function defines a two-dimensional texture image using pixels from the current frame buffer, rather than from main memory as is the case for glTexImage2D1HIX0NK.

Using the mipmap level specified with level, texture arrays are defined as a rectangle of pixels with the lower-left corner located at the coordinates x and y, width equal to width + (2 * border), and a height equal to height + (2 * border). The internal format of the texture array is specified with the internalFormat parameter.

The glCopyTexImage2D function processes the pixels in a row in the same way as glCopyPixels173H6L except that before the final conversion of the pixels, all pixel component values are clamped to the range [0, 1] and converted to the texture s internal format for storage in the texture array. Pixel ordering is determined with lower x and y coordinates corresponding to lower s and t texture coordinates. If any of the pixels within a specified row of the current frame buffer are outside the window associated with the current rendering context, then their values are undefined.

You cannot include calls to glCopyTexImage2D in display lists.

 

Note  The glCopyTexImage2D function is only available in OpenGL version 1.1 or later.

Texturing has no effect in color-index mode. The glPixelStoreNHM7UO and glPixelTransfer6MW9.AX functions affect texture images in exactly the way they affect glDrawPixelsHZW_GG.

 

The following function retrieves information related to glCopyTexImage2D:

glIsEnabled1MZ_ZK. with argument GL_TEXTURE_2D

 

Error Codes

The following are the error codes generated and their conditions.

Error Code

Condition

GL_INVALID_ENUM

target was not an accepted value.

GL_INVALID_VALUE

level was less than zero or greater than log sub 2(max), where max is the returned value of GL_MAX_TEXTURE_SIZE.

GL_INVALID_VALUE

border was not zero or 1.

GL_INVALID_VALUE

width was less than zero, greater than 2 + GL_MAX_TEXTURE_SIZE; or width cannot be represented as 2^n + 2 * border for some integer n.

GL_INVALID_OPERATION

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

 

See Also

glBegin, glCopyTexImage1D, glDrawPixels, glEnd, glFog, glPixelStore, glPixelTransfer, glTexEnv, glTexGen, glTexImage1D, glTexImage2D, glTexParameter