files/en-us/web/api/webgl2renderingcontext/texstorage2d/index.md
{{APIRef("WebGL")}}{{AvailableInWorkers}}
The texStorage2D() method of the {{domxref("WebGL2RenderingContext")}} of the WebGL API specifies all levels of two-dimensional texture storage.
texStorage2D(target, levels, internalformat, width, height)
target
gl.TEXTURE_2D: A two-dimensional texture.gl.TEXTURE_CUBE_MAP: A cube-mapped texture.levels
internalformat
: A {{domxref("WebGL_API/Types", "GLenum")}} specifying the texture store format. Possible values:
gl.R8gl.R8_SNORMgl.R16Fgl.R32Fgl.R8UIgl.R8Igl.R16UIgl.R16Igl.R32UIgl.R32Igl.RG8gl.RG8_SNORMgl.RG16Fgl.RG32Fgl.RG8UIgl.RG8Igl.RG16UIgl.RG16Igl.RG32UIgl.RG32Igl.RGB8gl.SRGB8gl.RGB565gl.RGB8_SNORMgl.R11F_G11F_B10Fgl.RGB9_E5gl.RGB16Fgl.RGB32Fgl.RGB8UIgl.RGB8Igl.RGB16UIgl.RGB16Igl.RGB32UIgl.RGB32Igl.RGBA8gl.SRGB8_ALPHA8gl.RGBA8_SNORMgl.RGB5_A1gl.RGBA4gl.RGB10_A2gl.RGBA16Fgl.RGBA32Fgl.RGBA8UIgl.RGBA8Igl.RGB10_A2UIgl.RGBA16UIgl.RGBA16Igl.RGBA32UIgl.RGBA32Igl.DEPTH_COMPONENT16gl.DEPTH_COMPONENT24gl.DEPTH_COMPONENT32Fgl.DEPTH24_STENCIL8gl.DEPTH32F_STENCIL8Unlike OpenGL 3.0, WebGL 2 doesn't support the following ETC2 and EAC compressed texture formats (see section 5.37 in the WebGL 2 spec). You might be able to enable them via the {{domxref("WEBGL_compressed_texture_etc")}} extension, though.
gl.COMPRESSED_R11_EACgl.COMPRESSED_SIGNED_R11_EACgl.COMPRESSED_RG11_EACgl.COMPRESSED_SIGNED_RG11_EACgl.COMPRESSED_RGB8_ETC2gl.COMPRESSED_SRGB8_ETC2gl.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2gl.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2gl.COMPRESSED_RGBA8_ETC2_EACgl.COMPRESSED_SRGB8_ALPHA8_ETC2_EACFor the description of these formats, see {{domxref("WebGLRenderingContext.texImage2D()")}}. Because texStorage2D does not actually specify a buffer source, the format and type parameters are irrelevant, and can be considered to be any of the valid values corresponding to the internalformat.
width
height
None ({{jsxref("undefined")}}).
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGB8, 256, 256);
{{Specifications}}
{{Compat}}