GLAPI/glTexStorage2D

暂时偷懒一下,直接把openGL API复制过来,有空了,一定翻译成中文,大家请见谅

glTexStorage2D: simultaneously specify storage for all levels of a two-dimensional or one-dimensional array texture

Contents

 [hide] 

Function Definition

 void glTexStorage2D(GLenum target​, GLsizei levels​, GLenum internalformat​, GLsizei width​, GLsizei height​);

target

Specify the target of the operation. target​ must be one of GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D, GL_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP, or GL_PROXY_TEXTURE_CUBE_MAP.

levels

Specify the number of texture levels.

internalformat

Specifies the internal format to be used to store texture image data. This must be a sized image format.

width

Specifies the width of the texture, in texels.

height

Specifies the height of the texture, in texels.

Description

glTexStorage2D specifies the storage requirements for all levels of a two-dimensional texture or one-dimensional texture array 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 an immutable-format texture.

The behavior of glTexStorage2D depends on the target​ parameter. When target​ is GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D, GL_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_RECTANGLE or GL_PROXY_TEXTURE_CUBE_MAP, 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));
}

When target​ is GL_TEXTURE_1D or GL_TEXTURE_1D_ARRAY, glTexStorage2D is equivalent to:

for (i = 0; i < levels; i++)
{
    glTexImage2D(target, i, internalformat, width, height, 0, format, type, NULL);
    width = max(1, (width / 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 internal formats given in the tables 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.

Sized Internal Formats
  Component Bitdepth
Sized Internal FormatBase Internal FormatRedGreenBlueAlphaShared
GL_R8GL_RED8    
GL_R8_SNORMGL_REDs8    
GL_R16GL_RED16    
GL_R16_SNORMGL_REDs16    
GL_RG8GL_RG88   
GL_RG8_SNORMGL_RGs8s8   
GL_RG16GL_RG1616   
GL_RG16_SNORMGL_RGs16s16   
GL_R3_G3_B2GL_RGB332  
GL_RGB4GL_RGB444  
GL_RGB5GL_RGB555  
GL_RGB8GL_RGB888  
GL_RGB8_SNORMGL_RGBs8s8s8  
GL_RGB10GL_RGB101010  
GL_RGB12GL_RGB121212  
GL_RGB16_SNORMGL_RGB161616  
GL_RGBA2GL_RGB2222 
GL_RGBA4GL_RGB4444 
GL_RGB5_A1GL_RGBA5551 
GL_RGBA8GL_RGBA8888 
GL_RGBA8_SNORMGL_RGBAs8s8s8s8 
GL_RGB10_A2GL_RGBA1010102 
GL_RGB10_A2UIGL_RGBAui10ui10ui10ui2 
GL_RGBA12GL_RGBA12121212 
GL_RGBA16GL_RGBA16161616 
GL_SRGB8GL_RGB888  
GL_SRGB8_ALPHA8GL_RGBA8888 
GL_R16FGL_REDf16    
GL_RG16FGL_RGf16f16   
GL_RGB16FGL_RGBf16f16f16  
GL_RGBA16FGL_RGBAf16f16f16f16 
GL_R32FGL_REDf32    
GL_RG32FGL_RGf32f32   
GL_RGB32FGL_RGBf32f32f32  
GL_RGBA32FGL_RGBAf32f32f32f32 
GL_R11F_G11F_B10FGL_RGBf11f11f10  
GL_RGB9_E5GL_RGB999 5
GL_R8IGL_REDi8    
GL_R8UIGL_REDui8    
GL_R16IGL_REDi16    
GL_R16UIGL_REDui16    
GL_R32IGL_REDi32    
GL_R32UIGL_REDui32    
GL_RG8IGL_RGi8i8   
GL_RG8UIGL_RGui8ui8   
GL_RG16IGL_RGi16i16   
GL_RG16UIGL_RGui16ui16   
GL_RG32IGL_RGi32i32   
GL_RG32UIGL_RGui32ui32   
GL_RGB8IGL_RGBi8i8i8  
GL_RGB8UIGL_RGBui8ui8ui8  
GL_RGB16IGL_RGBi16i16i16  
GL_RGB16UIGL_RGBui16ui16ui16  
GL_RGB32IGL_RGBi32i32i32  
GL_RGB32UIGL_RGBui32ui32ui32  
GL_RGBA8IGL_RGBAi8i8i8i8 
GL_RGBA8UIGL_RGBAui8ui8ui8ui8 
GL_RGBA16IGL_RGBAi16i16i16i16 
GL_RGBA16UIGL_RGBAui16ui16ui16ui16 
GL_RGBA32IGL_RGBAi32i32i32i32 
GL_RGBA32UIGL_RGBAui32ui32ui32ui32 

 

Sized Depth and Stencil Internal Formats
  Component Bitdepth
Sized Internal FormatBase Internal FormatDepthStencil
GL_DEPTH_COMPONENT16GL_DEPTH_COMPONENT16 
GL_DEPTH_COMPONENT24GL_DEPTH_COMPONENT24 
GL_DEPTH_COMPONENT32GL_DEPTH_COMPONENT32 
GL_DEPTH_COMPONENT32FGL_DEPTH_COMPONENTf32 
GL_DEPTH24_STENCIL8GL_DEPTH_STENCIL248
GL_DEPTH32F_STENCIL8GL_DEPTH_STENCILf328
GL_STENCIL_INDEX8GL_STENCIL_INDEX 8

 

Compressed Internal Formats
Compressed Internal FormatBase Internal FormatType
GL_COMPRESSED_REDGL_REDGeneric
GL_COMPRESSED_RGGL_RGGeneric
GL_COMPRESSED_RGBGL_RGBGeneric
GL_COMPRESSED_RGBAGL_RGBAGeneric
GL_COMPRESSED_SRGBGL_RGBGeneric
GL_COMPRESSED_SRGB_ALPHAGL_RGBAGeneric
GL_COMPRESSED_RED_RGTC1GL_REDSpecific
GL_COMPRESSED_SIGNED_RED_RGTC1GL_REDSpecific
GL_COMPRESSED_RG_RGTC2GL_RGSpecific
GL_COMPRESSED_SIGNED_RG_RGTC2GL_RGSpecific
GL_COMPRESSED_RGBA_BPTC_UNORMGL_RGBASpecific
GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORMGL_RGBASpecific
GL_COMPRESSED_RGB_BPTC_SIGNED_FLOATGL_RGBSpecific
GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOATGL_RGBSpecific
S3TC formats
GL_COMPRESSED_RGB_S3TC_DXT1_EXTGL_RGBSpecific
GL_COMPRESSED_SRGB_S3TC_DXT1_EXTGL_RGBSpecific
GL_COMPRESSED_RGBA_S3TC_DXT1_EXTGL_RGBASpecific
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXTGL_RGBASpecific
GL_COMPRESSED_RGBA_S3TC_DXT3_EXTGL_RGBASpecific
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXTGL_RGBASpecific
GL_COMPRESSED_RGBA_S3TC_DXT5_EXTGL_RGBASpecific
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXTGL_RGBASpecific

 

Errors

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​ or levels​ are less than 1.

GL_INVALID_OPERATION is generated if target​ is GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY and levels​ is greater than {\displaystyle \left\lfloor \log _{2}(width)\right\rfloor +1}.

GL_INVALID_OPERATION is generated if target​ is not GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY and levels​ is greater than {\displaystyle \left\lfloor \log _{2}(max(width,height))\right\rfloor +1}.

See Also

glActiveTextureglBindTextureglTexStorage1DglTexStorage2DMultisampleglTexStorage3DglTexStorage3DMultisampleglTextureViewglTexSubImage2D

View textures and S3TC compressed formats

Copyright

Copyright © 2011 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/.

Categories

参考:

https://www.khronos.org/opengl/wiki/GLAPI/glTexStorage2D

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值