glFramebufferTexture2D
3G
glFramebufferTexture2D
attach a texture image to a framebuffer object
C Specification
void glFramebufferTexture2D
GLenum target
GLenum attachment
GLenum textarget
GLuint texture
GLint level
Parameters
target
Specifies the framebuffer target. The symbolic constant must be
GL_FRAMEBUFFER.
attachment
Specifies the attachment point to which an image from
texture should be attached. Must be one of the
following symbolic constants:
GL_COLOR_ATTACHMENT0,
GL_DEPTH_ATTACHMENT, or
GL_STENCIL_ATTACHMENT.
textarget
Specifies the texture target. Must be one of the
following symbolic constants:
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, or
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z.
texture
Specifies the texture object whose image is to be attached.
level
Specifies the mipmap level of the texture image to be attached,
which must be 0.
Description
glFramebufferTexture2D attaches the
texture image specified by texture and
level as
one of the logical buffers of the currently bound framebuffer object.
attachment specifies whether the texture image
should be attached to the framebuffer object's color, depth, or
stencil buffer. A texture image may not be attached to the default
framebuffer object name 0.
If texture is not 0, the value of
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE for the
specified attachment point is set to GL_TEXTURE,
the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
is set to texture, and the value of
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL is set to
level. If texture is a cube map
texture, the value of GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
is set to textarget; otherwise it is set to the default value
GL_TEXTURE_CUBE_MAP_POSITIVE_X. Any previous attachment to the
attachment logical buffer of the currently bound framebuffer
object is broken.
If texture is 0, the current image, if any, attached to
the attachment logical buffer of the currently bound
framebuffer object is detached. The value of
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is set to
GL_NONE. The value of
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME is set to 0.
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL and
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE are
set to the default values 0 and GL_TEXTURE_CUBE_MAP_POSITIVE_X,
respectively.
Notes
Special precautions need to be taken to avoid attaching a texture image to the
currently bound framebuffer while the texture object is currently bound and
potentially sampled by the current vertex or fragment shader. Doing so could lead to
the creation of a "feedback loop" between the writing of pixels by rendering operations
and the simultaneous reading of those same pixels when used as texels in the
currently bound texture. In this scenario, the framebuffer will be considered
framebuffer complete, but the values of fragments rendered while in this state will
be undefined. The values of texture samples may be undefined as well.
If a texture object is deleted while its image is attached to the currently
bound framebuffer, then it is as if glFramebufferTexture2D
had been called with a texture of 0 for the attachment
point to which this image was attached in the currently bound framebuffer object.
In other words, the texture image is detached from the currently bound
framebuffer. Note that the texture image is specifically not
detached from any non-bound framebuffers. Detaching the image from any non-bound
framebuffers is the responsibility of the application.
Errors
GL_INVALID_ENUM is generated if
target is not GL_FRAMEBUFFER.
GL_INVALID_ENUM is generated if
textarget is not an accepted texture target and
texture is not 0.
GL_INVALID_ENUM is generated if
attachment is not an accepted attachment point.
GL_INVALID_VALUE is generated if
level is not 0 and
texture is not 0.
GL_INVALID_OPERATION is generated if
the default framebuffer object name 0 is bound.
GL_INVALID_OPERATION is generated if
texture is neither 0 nor the name of an existing
texture object.
GL_INVALID_OPERATION is generated if
texture is the name of an existing two-dimensional
texture object but textarget is not
GL_TEXTURE_2D or if texture is
the name of an existing cube map texture object but textarget
is GL_TEXTURE_2D.
Associated Gets
glGetFramebufferAttachmentParameteriv
See Also
glBindFramebuffer,
glBindTexture,
glCheckFramebufferStatus,
glDeleteFramebuffers,
glDeleteTextures,
glFramebufferRenderbuffer,
glGenerateMipmap,
glGetFramebufferAttachmentParameteriv,
glTexImage2D
Copyright
Copyright 2008 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/.