files/en-us/web/api/webglrenderingcontext/copyteximage2d/index.md
{{APIRef("WebGL")}}{{AvailableInWorkers}}
The copyTexImage2D() method of the {{domxref("WebGLRenderingContext")}} interface of the WebGL API copies pixels from the current {{domxref("WebGLFramebuffer")}} into a 2D texture image.
copyTexImage2D(target, level, internalformat, x, y, width, height, border)
target
gl.TEXTURE_2D: A two-dimensional texture.gl.TEXTURE_CUBE_MAP_POSITIVE_X: Positive X face for a cube-mapped texture.gl.TEXTURE_CUBE_MAP_NEGATIVE_X: Negative X face for a cube-mapped texture.gl.TEXTURE_CUBE_MAP_POSITIVE_Y: Positive Y face for a cube-mapped texture.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y: Negative Y face for a cube-mapped texture.gl.TEXTURE_CUBE_MAP_POSITIVE_Z: Positive Z face for a cube-mapped texture.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z: Negative Z face for a cube-mapped texture.level
internalformat
gl.ALPHA: Discards the red, green and blue components and reads the alpha component.gl.RGB: Discards the alpha components and reads the red, green and blue components.gl.RGBA: Red, green, blue and alpha components are read from the color buffer.gl.LUMINANCE: Each color component is a luminance component, alpha is 1.0.gl.LUMINANCE_ALPHA: Each component is a luminance/alpha component.x
y
width
height
border
None ({{jsxref("undefined")}}).
gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 512, 512, 0);
{{Specifications}}
{{Compat}}