glTexStorage2D â simultaneously specify storage for all levels of a two-dimensional texture
C Specificationvoid glTexStorage2D(
GLenum target, Â GLsizei levels, Â GLenum internalformat, Â GLsizei width, Â GLsizei height)
;
Â
Parameterstarget
Specify the target of the operation. target
must be one of GL_TEXTURE_2D
, or GL_TEXTURE_CUBE_MAP
.
levels
Specify the number of texture levels.
internalformat
Specifies the sized internal format to be used to store texture image data.
width
Specifies the width of the texture, in texels.
height
Specifies the height of the texture, in texels.
glTexStorage2D
specifies the storage requirements for all levels of a two-dimensional texture simultaneously. Once a texture is specified with this command, the format and dimensions of all levels become immutable. The contents of the image may still be modified, however, its storage requirements may not change. Such a texture is referred to as an immutable-format texture.
The behavior of glTexStorage2D
depends on the target
parameter. When target
is GL_TEXTURE_2D
, calling glTexStorage2D
is equivalent, assuming no errors are generated, to executing the following pseudo-code:
for (i = 0; i < levels; i++) { glTexImage2D(target, i, internalformat, width, height, 0, format, type, NULL); width = max(1, (width / 2)); height = max(1, (height / 2)); }
When target
is GL_TEXTURE_CUBE_MAP
, glTexStorage2D
is equivalent to:
for (i = 0; i < levels; i++) { for (face in (+X, -X, +Y, -Y, +Z, -Z)) { glTexImage2D(face, i, internalformat, width, height, 0, format, type, NULL); } width = max(1, (width / 2)); height = max(1, (height / 2)); }
Since no texture data is actually provided, the values used in the pseudo-code for format
and type
are irrelevant and may be considered to be any values that are legal for the chosen internalformat
enumerant. internalformat
must be one of the sized internal formats given in Table 1, or one of the compressed internal formats given in Table 2 below. Upon success, the value of GL_TEXTURE_IMMUTABLE_FORMAT
becomes GL_TRUE
. The value of GL_TEXTURE_IMMUTABLE_FORMAT
may be discovered by calling glGetTexParameter with pname
set to GL_TEXTURE_IMMUTABLE_FORMAT
. No further changes to the dimensions or format of the texture object may be made. Using any command that might alter the dimensions or format of the texture object (such as glTexImage2D or another call to glTexStorage2D
) will result in the generation of a GL_INVALID_OPERATION
error, even if it would not, in fact, alter the dimensions or format of the object.
Table 1. Sized Internal Formats
Sized Internal Format Format Type Red Bits Green Bits Blue Bits Alpha Bits Shared Bits Color renderable Texture filterableGL_R8
GL_RED
GL_UNSIGNED_BYTE
8 Â Â Â Â Y Y GL_R8_SNORM
GL_RED
GL_BYTE
s8 Â Â Â Â Â Y GL_R16F
GL_RED
GL_HALF_FLOAT
,GL_FLOAT
f16 Â Â Â Â Â Y GL_R32F
GL_RED
GL_FLOAT
f32 Â Â Â Â Â Â GL_R8UI
GL_RED_INTEGER
GL_UNSIGNED_BYTE
ui8 Â Â Â Â Y Â GL_R8I
GL_RED_INTEGER
GL_BYTE
i8 Â Â Â Â Y Â GL_R16UI
GL_RED_INTEGER
GL_UNSIGNED_SHORT
ui16 Â Â Â Â Y Â GL_R16I
GL_RED_INTEGER
GL_SHORT
i16 Â Â Â Â Y Â GL_R32UI
GL_RED_INTEGER
GL_UNSIGNED_INT
ui32 Â Â Â Â Y Â GL_R32I
GL_RED_INTEGER
GL_INT
i32 Â Â Â Â Y Â GL_RG8
GL_RG
GL_UNSIGNED_BYTE
8 8 Â Â Â Y Y GL_RG8_SNORM
GL_RG
GL_BYTE
s8 s8 Â Â Â Â Y GL_RG16F
GL_RG
GL_HALF_FLOAT
,GL_FLOAT
f16 f16 Â Â Â Â Y GL_RG32F
GL_RG
GL_FLOAT
f32 f32 Â Â Â Â Â GL_RG8UI
GL_RG_INTEGER
GL_UNSIGNED_BYTE
ui8 ui8 Â Â Â Y Â GL_RG8I
GL_RG_INTEGER
GL_BYTE
i8 i8 Â Â Â Y Â GL_RG16UI
GL_RG_INTEGER
GL_UNSIGNED_SHORT
ui16 ui16 Â Â Â Y Â GL_RG16I
GL_RG_INTEGER
GL_SHORT
i16 i16 Â Â Â Y Â GL_RG32UI
GL_RG_INTEGER
GL_UNSIGNED_INT
ui32 ui32 Â Â Â Y Â GL_RG32I
GL_RG_INTEGER
GL_INT
i32 i32 Â Â Â Y Â GL_RGB8
GL_RGB
GL_UNSIGNED_BYTE
8 8 8 Â Â Y Y GL_SRGB8
GL_RGB
GL_UNSIGNED_BYTE
8 8 8 Â Â Â Y GL_RGB565
GL_RGB
GL_UNSIGNED_BYTE
, GL_UNSIGNED_SHORT_5_6_5
5 6 5 Â Â Y Y GL_RGB8_SNORM
GL_RGB
GL_BYTE
s8 s8 s8 Â Â Â Y GL_R11F_G11F_B10F
GL_RGB
GL_UNSIGNED_INT_10F_11F_11F_REV
, GL_HALF_FLOAT
, GL_FLOAT
f11 f11 f10 Â Â Â Y GL_RGB9_E5
GL_RGB
GL_UNSIGNED_INT_5_9_9_9_REV
, GL_HALF_FLOAT
, GL_FLOAT
9 9 9 Â 5 Â Y GL_RGB16F
GL_RGB
GL_HALF_FLOAT
, GL_FLOAT
f16 f16 f16 Â Â Â Y GL_RGB32F
GL_RGB
GL_FLOAT
f32 f32 f32 Â Â Â Â GL_RGB8UI
GL_RGB_INTEGER
GL_UNSIGNED_BYTE
ui8 ui8 ui8 Â Â Â Â GL_RGB8I
GL_RGB_INTEGER
GL_BYTE
i8 i8 i8 Â Â Â Â GL_RGB16UI
GL_RGB_INTEGER
GL_UNSIGNED_SHORT
ui16 ui16 ui16 Â Â Â Â GL_RGB16I
GL_RGB_INTEGER
GL_SHORT
i16 i16 i16 Â Â Â Â GL_RGB32UI
GL_RGB_INTEGER
GL_UNSIGNED_INT
ui32 ui32 ui32 Â Â Â Â GL_RGB32I
GL_RGB_INTEGER
GL_INT
i32 i32 i32 Â Â Â Â GL_RGBA8
GL_RGBA
GL_UNSIGNED_BYTE
8 8 8 8 Â Y Y GL_SRGB8_ALPHA8
GL_RGBA
GL_UNSIGNED_BYTE
8 8 8 8 Â Y Y GL_RGBA8_SNORM
GL_RGBA
GL_BYTE
s8 s8 s8 s8 Â Â Y GL_RGB5_A1
GL_RGBA
GL_UNSIGNED_BYTE
, GL_UNSIGNED_SHORT_5_5_5_1
, GL_UNSIGNED_INT_2_10_10_10_REV
5 5 5 1 Â Y Y GL_RGBA4
GL_RGBA
GL_UNSIGNED_BYTE
, GL_UNSIGNED_SHORT_4_4_4_4
4 4 4 4 Â Y Y GL_RGB10_A2
GL_RGBA
GL_UNSIGNED_INT_2_10_10_10_REV
10 10 10 2 Â Y Y GL_RGBA16F
GL_RGBA
GL_HALF_FLOAT
, GL_FLOAT
f16 f16 f16 f16 Â Â Y GL_RGBA32F
GL_RGBA
GL_FLOAT
f32 f32 f32 f32 Â Â Â GL_RGBA8UI
GL_RGBA_INTEGER
GL_UNSIGNED_BYTE
ui8 ui8 ui8 ui8 Â Y Â GL_RGBA8I
GL_RGBA_INTEGER
GL_BYTE
i8 i8 i8 i8 Â Y Â GL_RGB10_A2UI
GL_RGBA_INTEGER
GL_UNSIGNED_INT_2_10_10_10_REV
ui10 ui10 ui10 ui2 Â Y Â GL_RGBA16UI
GL_RGBA_INTEGER
GL_UNSIGNED_SHORT
ui16 ui16 ui16 ui16 Â Y Â GL_RGBA16I
GL_RGBA_INTEGER
GL_SHORT
i16 i16 i16 i16 Â Y Â GL_RGBA32I
GL_RGBA_INTEGER
GL_INT
i32 i32 i32 i32 Â Y Â GL_RGBA32UI
GL_RGBA_INTEGER
GL_UNSIGNED_INT
ui32 ui32 ui32 ui32 Â Y Â Sized Internal Format Format Type Depth Bits Stencil Bits GL_DEPTH_COMPONENT16
GL_DEPTH_COMPONENT
GL_UNSIGNED_SHORT
, GL_UNSIGNED_INT
16 Â GL_DEPTH_COMPONENT24
GL_DEPTH_COMPONENT
GL_UNSIGNED_INT
24 Â GL_DEPTH_COMPONENT32F
GL_DEPTH_COMPONENT
GL_FLOAT
f32 Â GL_DEPTH24_STENCIL8
GL_DEPTH_STENCIL
GL_UNSIGNED_INT_24_8
24 8 GL_DEPTH32F_STENCIL8
GL_DEPTH_STENCIL
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
f32 8
Table 2. Compressed Internal Formats
Compressed Internal Format Base Internal Format Image SizeGL_COMPRESSED_R11_EAC
GL_RED
ceil(width
/4) * ceil(height
/4) * 8 GL_COMPRESSED_SIGNED_R11_EAC
GL_RED
ceil(width
/4) * ceil(height
/4) * 8 GL_COMPRESSED_RG11_EAC
GL_RG
ceil(width
/4) * ceil(height
/4) * 16 GL_COMPRESSED_SIGNED_RG11_EAC
GL_RG
ceil(width
/4) * ceil(height
/4) * 16 GL_COMPRESSED_RGB8_ETC2
GL_RGB
ceil(width
/4) * ceil(height
/4) * 8 GL_COMPRESSED_SRGB8_ETC2
GL_RGB
ceil(width
/4) * ceil(height
/4) * 8 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
GL_RGBA
ceil(width
/4) * ceil(height
/4) * 8 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
GL_RGBA
ceil(width
/4) * ceil(height
/4) * 8 GL_COMPRESSED_RGBA8_ETC2_EAC
GL_RGBA
ceil(width
/4) * ceil(height
/4) * 16 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
GL_RGBA
ceil(width
/4) * ceil(height
/4) * 16 Errors
GL_INVALID_OPERATION
is generated if the default texture object is curently bound to target
.
GL_INVALID_OPERATION
is generated if the texture object curently bound to target
already has GL_TEXTURE_IMMUTABLE_FORMAT
set to GL_TRUE
.
GL_INVALID_ENUM
is generated if internalformat
is not a valid sized internal format.
GL_INVALID_ENUM
is generated if target
is not one of the accepted target enumerants.
GL_INVALID_VALUE
is generated if width
, height
or levels
are less than 1.
GL_INVALID_OPERATION
is generated if levels
is greater than log 2 max width , Â height + 1 .
Copyright © 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. https://opencontent.org/openpub/.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4