opengl API glFramebufferTexture2D详解

中文解释:

名称
glFramebufferTexture2D - 将纹理图像附加到帧缓冲对象

C规范
void glFramebufferTexture2D(GLenum target,

                                                      GLenum attachment,

                                                      GLenum textarget,

                                                      GLuint texture,

                                                      GLint level);

参数
target

指定帧缓冲目标。 符号常量必须是GL_FRAMEBUFFER。

attachment

指定应附加纹理图像的附着点。 必须是以下符号常量之一:GL_COLOR_ATTACHMENT0,GL_DEPTH_ATTACHMENT或GL_STENCIL_ATTACHMENT。

textarget

指定纹理目标。 必须是以下符号常量之一:GL_TEXTURE_2D,GL_TEXTURE_CUBE_MAP_POSITIVE_X,GL_TEXTURE_CUBE_MAP_NEGATIVE_X,GL_TEXTURE_CUBE_MAP_POSITIVE_Y,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,GL_TEXTURE_CUBE_MAP_POSITIVE_Z或GL_TEXTURE_CUBE_MAP_NEGATIVE_Z。

texture

指定要附加图像的纹理对象。

level

指定要附加的纹理图像的mipmap级别,该级别必须为0。

描述
glFramebufferTexture2D将texture和level指定的纹理图像附加为当前绑定的帧缓冲区对象的逻辑缓冲区之一。 attachment指定是否应将纹理图像附加到帧缓冲对象的颜色,深度或模板缓冲区。 纹理图像不可以附加到默认(名称为0)的帧缓冲对象。

如果texture不为0,则指定附加点的GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE的值设置为GL_TEXTURE,GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME的值设置为texture,GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL的值设置为level。 如果纹理是立方体贴图纹理,则GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE的值设置为textarget; 否则将其设置为默认值GL_TEXTURE_CUBE_MAP_POSITIVE_X。 先前绑定的帧缓冲区对象的附件逻辑缓冲区都将被破坏。

如果texture为0,则分离附加到当前绑定的帧缓冲区对象的附件逻辑缓冲区的当前图像(如果有的话)。 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE的值设置为GL_NONE。 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME的值设置为0. GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL和GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE分别设置为默认值0和GL_TEXTURE_CUBE_MAP_POSITIVE_X。

注意
当纹理对象当前被绑定并可能被当前顶点或片段着色器采样时,需要采取特殊预防措施以避免将纹理图像附加到当前绑定的帧缓冲区。这样做可能导致在通过渲染操作写入像素和在当前绑定纹理中用作纹素时同时读取那些相同像素之间创建“反馈循环”。在这种情况下,帧缓冲区将被视为帧缓冲区完成,但在此状态下渲染的片段的值将是未定义的。纹理样本的值也可能是未定义的。

如果在将图像附加到当前绑定的帧缓冲区时删除纹理对象,这就好比使用纹理0调用glFramebufferTexture2D作为此图像附加到当前绑定的帧缓冲区对象中的附着点。换句话说,纹理图像与当前绑定的帧缓冲区分离了。请注意,纹理图像不会与任何未绑定的帧缓冲区分离。从任何非绑定帧缓冲区中分离映像是应用程序的责任。

错误
GL_INVALID_ENUM :target不是GL_FRAMEBUFFER。

GL_INVALID_ENUM :texture不为0时textarget不是可接收的纹理target。

GL_INVALID_ENUM :attachment是不可接收的附着点。

GL_INVALID_VALUE :level不是0时,texture不是0。

GL_INVALID_OPERATION :如果绑定了默认的帧缓冲对象名称0。

GL_INVALID_OPERATION :如果texture既不是0也不是现有纹理对象的名称。

GL_INVALID_OPERATION :如果texture是现有二维纹理对象的名称,但textarget不是GL_TEXTURE_2D,或者texture是现有立方体贴图纹理对象的名称,但textarget是GL_TEXTURE_2D。

相关Gets
glGetFramebufferAttachmentParameteriv

另见
glBindFramebuffer,glBindTexture,glCheckFramebufferStatus,glDeleteFramebuffers,glDeleteTextures,glFramebufferRenderbuffer,glGenerateMipmap,glGetFramebufferAttachmentParameteriv,glTexImage2D

版权
https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glFramebufferTexture2D.xml

https://blog.csdn.net/flycatdeng

Copyright © 1991-2006 Silicon Graphics, Inc.本文档的许可是根据SGI Free Software B License.详见http://oss.sgi.com/projects/FreeB/.

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

Contents
1 Function Definition
2 Description
3 Errors
4 See Also
5 Copyright
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 Format Base Internal Format Red Green Blue Alpha Shared
GL_R8 GL_RED 8
GL_R8_SNORM GL_RED s8
GL_R16 GL_RED 16
GL_R16_SNORM GL_RED s16
GL_RG8 GL_RG 8 8
GL_RG8_SNORM GL_RG s8 s8
GL_RG16 GL_RG 16 16
GL_RG16_SNORM GL_RG s16 s16
GL_R3_G3_B2 GL_RGB 3 3 2
GL_RGB4 GL_RGB 4 4 4
GL_RGB5 GL_RGB 5 5 5
GL_RGB8 GL_RGB 8 8 8
GL_RGB8_SNORM GL_RGB s8 s8 s8
GL_RGB10 GL_RGB 10 10 10
GL_RGB12 GL_RGB 12 12 12
GL_RGB16_SNORM GL_RGB 16 16 16
GL_RGBA2 GL_RGB 2 2 2 2
GL_RGBA4 GL_RGB 4 4 4 4
GL_RGB5_A1 GL_RGBA 5 5 5 1
GL_RGBA8 GL_RGBA 8 8 8 8
GL_RGBA8_SNORM GL_RGBA s8 s8 s8 s8
GL_RGB10_A2 GL_RGBA 10 10 10 2
GL_RGB10_A2UI GL_RGBA ui10 ui10 ui10 ui2
GL_RGBA12 GL_RGBA 12 12 12 12
GL_RGBA16 GL_RGBA 16 16 16 16
GL_SRGB8 GL_RGB 8 8 8
GL_SRGB8_ALPHA8 GL_RGBA 8 8 8 8
GL_R16F GL_RED f16
GL_RG16F GL_RG f16 f16
GL_RGB16F GL_RGB f16 f16 f16
GL_RGBA16F GL_RGBA f16 f16 f16 f16
GL_R32F GL_RED f32
GL_RG32F GL_RG f32 f32
GL_RGB32F GL_RGB f32 f32 f32
GL_RGBA32F GL_RGBA f32 f32 f32 f32
GL_R11F_G11F_B10F GL_RGB f11 f11 f10
GL_RGB9_E5 GL_RGB 9 9 9 5
GL_R8I GL_RED i8
GL_R8UI GL_RED ui8
GL_R16I GL_RED i16
GL_R16UI GL_RED ui16
GL_R32I GL_RED i32
GL_R32UI GL_RED ui32
GL_RG8I GL_RG i8 i8
GL_RG8UI GL_RG ui8 ui8
GL_RG16I GL_RG i16 i16
GL_RG16UI GL_RG ui16 ui16
GL_RG32I GL_RG i32 i32
GL_RG32UI GL_RG ui32 ui32
GL_RGB8I GL_RGB i8 i8 i8
GL_RGB8UI GL_RGB ui8 ui8 ui8
GL_RGB16I GL_RGB i16 i16 i16
GL_RGB16UI GL_RGB ui16 ui16 ui16
GL_RGB32I GL_RGB i32 i32 i32
GL_RGB32UI GL_RGB ui32 ui32 ui32
GL_RGBA8I GL_RGBA i8 i8 i8 i8
GL_RGBA8UI GL_RGBA ui8 ui8 ui8 ui8
GL_RGBA16I GL_RGBA i16 i16 i16 i16
GL_RGBA16UI GL_RGBA ui16 ui16 ui16 ui16
GL_RGBA32I GL_RGBA i32 i32 i32 i32
GL_RGBA32UI GL_RGBA ui32 ui32 ui32 ui32

Sized Depth and Stencil Internal Formats
Component Bitdepth
Sized Internal Format Base Internal Format Depth Stencil
GL_DEPTH_COMPONENT16 GL_DEPTH_COMPONENT 16
GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT 24
GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT 32
GL_DEPTH_COMPONENT32F GL_DEPTH_COMPONENT f32
GL_DEPTH24_STENCIL8 GL_DEPTH_STENCIL 24 8
GL_DEPTH32F_STENCIL8 GL_DEPTH_STENCIL f32 8
GL_STENCIL_INDEX8 GL_STENCIL_INDEX 8

Compressed Internal Formats
Compressed Internal Format Base Internal Format Type
GL_COMPRESSED_RED GL_RED Generic
GL_COMPRESSED_RG GL_RG Generic
GL_COMPRESSED_RGB GL_RGB Generic
GL_COMPRESSED_RGBA GL_RGBA Generic
GL_COMPRESSED_SRGB GL_RGB Generic
GL_COMPRESSED_SRGB_ALPHA GL_RGBA Generic
GL_COMPRESSED_RED_RGTC1 GL_RED Specific
GL_COMPRESSED_SIGNED_RED_RGTC1 GL_RED Specific
GL_COMPRESSED_RG_RGTC2 GL_RG Specific
GL_COMPRESSED_SIGNED_RG_RGTC2 GL_RG Specific
GL_COMPRESSED_RGBA_BPTC_UNORM GL_RGBA Specific
GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM GL_RGBA Specific
GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT GL_RGB Specific
GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT GL_RGB Specific
S3TC formats
GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_RGB Specific
GL_COMPRESSED_SRGB_S3TC_DXT1_EXT GL_RGB Specific
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_RGBA Specific
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT GL_RGBA Specific
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_RGBA Specific
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT GL_RGBA Specific
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_RGBA Specific
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT GL_RGBA Specific

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}{\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}\left\lfloor \log _{2}(max(width,height))\right\rfloor +1.

See Also
glActiveTexture, glBindTexture, glTexStorage1D, glTexStorage2DMultisample, glTexStorage3D, glTexStorage3DMultisample, glTextureView, glTexSubImage2D

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: Pages with syntax highlighting errorsCore API ReferenceCore API Ref TexturingTexture Object API State Functions

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

https://blog.csdn.net/flycatdeng/article/details/82667117

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值