WebGL
The texStorage2D() method of the WebGL2RenderingContext of the WebGL API specifies all levels of two-dimensional texture storage.
Syntax
texStorage2D(target, levels, internalformat, width, height)
Parameters
-
target- : A WebGL_API/Types specifying the binding point (target) of the active texture. Possible values:
gl.TEXTURE_2D: A two-dimensional texture.gl.TEXTURE_CUBE_MAP: A cube-mapped texture.
- : A WebGL_API/Types specifying the binding point (target) of the active texture. Possible values:
-
levels- : A WebGL_API/Types specifying the number of texture levels.
-
internalformat-
: A WebGL_API/Types 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_STENCIL8
Unlike 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 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_EAC
For the description of these formats, see WebGLRenderingContext.texImage2D(). Because
texStorage2Ddoes not actually specify a buffer source, theformatandtypeparameters are irrelevant, and can be considered to be any of the valid values corresponding to theinternalformat.
-
-
width- : A WebGL_API/Types specifying the width of the texture in texels.
-
height- : A WebGL_API/Types specifying the height of the texture in texels.
Return value
None (undefined).
Examples
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGB8, 256, 256);
Specifications
Browser compatibility
See also
- WebGL2RenderingContext.texStorage3D()
- WEBGL_compressed_texture_etc
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
