glTexStorage3D

From OpenGL Reference
Jump to navigation Jump to search

Simultaneously specify storage for all levels of a three-dimensional, two-dimensional array or cube-map array texture.

C Specification[edit]

void glTexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth );
void glTextureStorage3D( GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth );


Parameters[edit]

target - Specifies the target to which the texture object is bound for glTexStorage3D . Must be one of GL_TEXTURE_3D , GL_TEXTURE_2D_ARRAY , GL_TEXTURE_CUBE_MAP_ARRAY , GL_PROXY_TEXTURE_3D , GL_PROXY_TEXTURE_2D_ARRAY or GL_PROXY_TEXTURE_CUBE_MAP_ARRAY .
texture - Specifies the texture object name for glTextureStorage3D . The effective target of texture must be one of the valid non-proxy target values above.
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.
depth - Specifies the depth of the texture, in texels.


Description[edit]

 glTexStorage3D and glTextureStorage3D specify the storage requirements for all levels of a three-dimensional, two-dimensional array or cube-map array texture simultaneously. Once a texture is specified with this command, the format and dimensions of all levels become immutable unless it is a proxy texture. The contents of the image may still be modified, however, its storage requirements may not change. Such a texture is referred to as animmutable-formattexture.

The behavior of glTexStorage3D depends on the target parameter. When target is GL_TEXTURE_3D , or GL_PROXY_TEXTURE_3D , calling glTexStorage3D is equivalent, assuming no errors are generated, to executing the following pseudo-code:

   for (i = 0; i < levels; i++) {
       glTexImage3D(target, i, internalformat, width, height, depth, 0, format, type, NULL);
       width = max(1, (width / 2));
       height = max(1, (height / 2));
       depth = max(1, (depth / 2));
   }

When target is GL_TEXTURE_2D_ARRAY , GL_PROXY_TEXTURE_2D_ARRAY , GL_TEXTURE_CUBE_MAP_ARRAY , or GL_PROXY_TEXTURE_CUBE_MAP_ARRAY , glTexStorage3D is equivalent to:

   for (i = 0; i < levels; i++) {
       glTexImage3D(target, i, internalformat, width, height, depth, 0, format, type, NULL);
       width = max(1, (width / 2));
       height = max(1, (height / 2));
   }

Calling glTextureStorage3D is equivalent to the above pseudo-code, where target is the effective target of texture and it is as if texture were bound to target for the purposes of glTexImage3D .

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 below, one of the sized depth-component formats GL_DEPTH_COMPONENT32F , GL_DEPTH_COMPONENT24 , or GL_DEPTH_COMPONENT16 , one of the combined depth-stencil formats, GL_DEPTH32F_STENCIL8 , or GL_DEPTH24_STENCIL8 , or the stencil-only format, GL_STENCIL_INDEX8 . 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 glTexImage3D or another call to glTexStorage3D ) 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.



Notes[edit]

 GL_STENCIL_INDEX8 is accepted for internalformat only if the GL version is 4.4 or higher.


Errors[edit]

 GL_INVALID_OPERATION is generated by glTexStorage3D if zero is bound to target .

 GL_INVALID_OPERATION is generated by glTextureStorage3D if texture is not the name of an existing texture object.

 GL_INVALID_ENUM is generated if internalformat is not a valid sized internal format.

 GL_INVALID_ENUM is generated if target or the effective target of texture is not one of the accepted targets described above.

 GL_INVALID_VALUE is generated if width , height , depth or levels are less than 1.

 GL_INVALID_OPERATION is generated if target is GL_TEXTURE_3D or GL_PROXY_TEXTURE_3D and levels is greater than [math]⌊⌋+1[/math] .

 GL_INVALID_OPERATION is generated if target is GL_TEXTURE_2D_ARRAY , GL_PROXY_TEXTURE_2D_ARRAY , GL_TEXURE_CUBE_MAP_ARRAY , or GL_PROXY_TEXTURE_CUBE_MAP_ARRAY and levels is greater than [math]⌊⌋+1[/math] .


Version Support[edit]

 glTexStorage3D  4.2+
 glTextureStorage3D  4.5+

See Also[edit]

 glTexImage3D , glTexStorage1D , glTexStorage2D .


Copyright[edit]

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. http://opencontent.org/openpub/.