---
name: "glCopyTexImage2D"
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/glCopyTexImage2D"
---

# glCopyTexImage2D(3x)

copy pixels into a 2D texture image

## NAME

**glCopyTexImage2D** - copy pixels into a 2D texture image

## C SPECIFICATION

void **glCopyTexImage2D**( GLenum *target*,

```
	GLint level,
	GLenum internalformat,
	GLint x,
	GLint y,
	GLsizei width,
	GLsizei height,
	GLint border )
```

delim $$

## PARAMETERS

- *target*

  Specifies the target texture. Must be **GL\_TEXTURE\_2D**.

- *level*

  Specifies the level-of-detail number. Level 0 is the base image level. Level *n* is the *n*th mipmap reduction image.

- *internalformat*

  Specifies the internal  of the texture. 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\_RGB**, **GL\_R3\_G3\_B2**, **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**, or **GL\_RGBA16**.

- *x*, *y*

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

- *width*

  Specifies the width of the texture image. Must be 0 or $2 sup n ~+~ 2\*$*border* for some integer $n$.

- *height*

  Specifies the height of the texture image. Must be 0 or $2 sup m ~+~ 2\*$*border* for some integer $m$.

- *border*

  Specifies the width of the border. Must be either 0 or 1.

## DESCRIPTION

**glCopyTexImage2D** defines a two-dimensional texture image with pixels from the current **GL\_READ\_BUFFER**.

The screen-aligned pixel rectangle with lower left corner at (*x*, *y*) and with a width of *width*$~+~2~\*~$*border* and a height of *height*$~+~2~\*~$*border*  defines the texture array at the mipmap level specified by *level*. *internalformat* specifies the internal  of the texture array.

The pixels in the rectangle are processed exactly as if **glCopyPixels** had been called, but the process stops just before final conversion. At this point all pixel component values are clamped to the range $\[0,1\]$ and then converted to the texture's internal  for storage in the texel array.

Pixel ordering is such that lower $x$ and $y$ screen coordinates correspond to  lower $s$ and $t$ texture coordinates.

If any of the pixels within the specified rectangle of the current **GL\_READ\_BUFFER** are outside the window associated with the current rendering context, then the values obtained for those pixels are undefined.

## NOTES

**glCopyTexImage2D** is available only if the GL version is 1.1 or greater.

Texturing has no effect in color index mode.

1, 2, 3, and 4 are not accepted values for *internalformat*.

An image with height or width of 0 indicates a NULL texture.

When the **GL\_ARB\_imaging** extension is supported, the RGBA components read from the framebuffer may be processed by the imaging pipeline.  See **glTexImage1D** for specific details.

## ERRORS

**GL\_INVALID\_ENUM** is generated if *target* is not **GL\_TEXTURE\_2D**.

**GL\_INVALID\_VALUE** is generated if *level* is less than 0.

**GL\_INVALID\_VALUE** may be generated if *level* is greater than $log sub 2 max$, where $max$ is the returned value of **GL\_MAX\_TEXTURE\_SIZE**.

**GL\_INVALID\_VALUE** is generated if *width* or *height* is less than 0, greater than $2~+~$**GL\_MAX\_TEXTURE\_SIZE**, or if *width* or *height* cannot be represented as $2 sup k ~+~ 2~\*~$*border* for some integer $k$.

**GL\_INVALID\_VALUE** is generated if *border* is not 0 or 1.

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

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

## ASSOCIATED GETS

**glGetTexImage**\
 **glIsEnabled** with argument **GL\_TEXTURE\_2D**

## SEE ALSO

**glCopyPixels(3G)**, **glCopyTexImage1D(3G)**, **glCopyTexSubImage1D(3G)**, **glCopyTexSubImage2D(3G)**, **glPixelStore(3G)**, **glPixelTransfer(3G)**, **glTexEnv(3G)**, **glTexGen(3G)**, **glTexImage1D(3G)**, **glTexImage2D(3G)**, **glTexSubImage1D(3G)**, **glTexSubImage2D(3G)**,\
 **glTexParameter(3G)**
