glCopyTexSubImage2D Function
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height
);
| Name | Description | |
|---|---|---|
| in | target | Target texture. |
| in | level | Mipmap level of the data to load. |
| in | xoffset | X coordinate at the lower-left corner of the partial texture region to copy to. |
| in | yoffset | Y coordinate at the lower-left corner of the partial texture region to copy to. |
| in | x | X coordinate at the lower-left corner of the color buffer's copy region. |
| in | y | Y coordinate at the lower-left corner of the color buffer's copy region. |
| in | width | Width of the region read from the color buffer. |
| in | height | Height of the region read from the color buffer. |
Partially copies the content of the current color buffer into texture data.
Use this function to copy only a portion of the image processed by the glCopyTexImage2D function. The texture image must be created using the glTexImage2D function before you can call this function.
You can set target to one of the following values.
GL_TEXTURE_2D | 2D texture. |
|---|---|
GL_TEXTURE_CUBE_MAP_NEGATIVE_X | Face of a cube-map texture in the negative x direction. |
GL_TEXTURE_CUBE_MAP_POSITIVE_X | Face of a cube-map texture in the positive x direction. |
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y | Face of a cube-map texture in the negative y direction. |
GL_TEXTURE_CUBE_MAP_POSITIVE_Y | Face of a cube-map texture in the positive y direction. |
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z | Face of a cube-map texture in the negative z direction. |
GL_TEXTURE_CUBE_MAP_POSITIVE_Z | Face of a cube-map texture in the positive z direction. |
When you specify -2 or less for the level argument, all textures other than for the lowest mipmap level are automatically generated. Automatic mipmap generation is only supported for some texture formats. Also, the minimum generatable texture widths and heights (LOD upper limit) are different for each texture format. The following table shows the supported values for format and type and the minimum generatable sizes.
| format | type | Minimum automatically generatable size (in texels) |
GL_RGBA | GL_UNSIGNED_SHORT_4_4_4_4 | 64 |
GL_RGBA | GL_UNSIGNED_SHORT_5_5_5_1 | 64 |
GL_RGBA | GL_UNSIGNED_BYTE | 32 |
GL_RGB | GL_UNSIGNED_SHORT_5_6_5 | 64 |
GL_RGB | GL_UNSIGNED_BYTE | 32 |
GL_RGBA_NATIVE_DMP | GL_UNSIGNED_SHORT_4_4_4_4 | 64 |
GL_RGBA_NATIVE_DMP | GL_UNSIGNED_SHORT_5_5_5_1 | 64 |
GL_RGBA_NATIVE_DMP | GL_UNSIGNED_BYTE | 32 |
GL_RGB_NATIVE_DMP | GL_UNSIGNED_SHORT_5_6_5 | 64 |
GL_RGB_NATIVE_DMP | GL_UNSIGNED_BYTE | 32 |
GL_INVALID_OPERATION error. When GL_GENERATE_MIPMAP is TRUE, you must specify the same value for level as was specified in the previous call to TexImage2D or CopyTexImage2D. Specifying a different value for level causes an error. When GL_GENERATE_MIPMAP is FALSE, you must specify 0 for level. Any other value causes an error.
You must set xoffset, yoffset, x, y, width, and height to multiples of 8.
You can copy the current depth buffer to a texture and use that. Call the glEnable function and specify GL_DEPTH_STENCIL_COPY_DMP to enable the depth stencil copy feature. Call the glDisable function to disable this feature. Call the glIsEnabled function and specify GL_DEPTH_STENCIL_COPY_DMP to find if the depth stencil copy feature is enabled.
The format of the target texture for copying is determined by the format of the current depth buffer. Format conversion when copying is not supported. The format of the current depth buffer corresponds to the format of the target texture for copying as follows.
| Depth Buffer Format | Depth Buffer Content | Corresponding Texture Format (Texture Type) |
|---|---|---|
GL_DEPTH24_STENCIL8_EXT | R: 8-bit stencil value G: 24-bit depth value, bits [23:16] B: 24-bit depth value, bits [15:8] A: 24-bit depth value, bits [7:0] | GL_RGBA (GL_UNSIGNED_BYTE), GL_RGBA_NATIVE_DMP (GL_UNSIGNED_BYTE) |
GL_DEPTH_COMPONENT24_OES | R: 24-bit depth value, bits [23:16] G: 24-bit depth value, bits [15:8] B: 24-bit depth value, bits [7:0] | GL_RGB (GL_UNSIGNED_BYTE), GL_RGB_NATIVE_DMP (GL_UNSIGNED_BYTE) |
GL_DEPTH_COMPONENT16 | R: 16-bit depth value, bits [15:8] G: 16-bit depth value, bits [7:0] | GL_HILO8_DMP (GL_UNSIGNED_BYTE), GL_HILO8_NATIVE_DMP (GL_UNSIGNED_BYTE) |
The following errors occur in this function.
GL_INVALID_FRAMEBUFFER_OPERATION | A color buffer has not been configured correctly for the current framebuffer. |
|---|---|
GL_INVALID_VALUE | The xoffset, yoffset, x, y, width, or height argument was set to an invalid value; the sum of xoffset and width exceeds the width (in pixels) of the color buffer; or the sum of yoffset and height exceeds the height (in pixels) of the color buffer. |
GL_INVALID_OPERATION | The level argument was set to an invalid value. |
GL_INVALID_ENUM | target was set to an invalid value. |
GL_INVALID_OPERATION | This function was called without any command-list objects bound. |
GL_INVALID_OPERATION | This function was called on a texture object with a texture format that does not correspond to the current depth buffer format. |
glTexImage2D function.
CONFIDENTIAL