framebufferTexture2D
FramebufferTexture2D is an OpenGL function used to attach a texture image to a framebuffer object (FBO). This enables rendering into a texture or sampling from that texture in subsequent passes.
Prototype: void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
- target selects the framebuffer binding point: GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_DRAW_FRAMEBUFFER.
- attachment specifies the attachment point on the framebuffer, such as GL_COLOR_ATTACHMENTi, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, or GL_DEPTH_STENCIL_ATTACHMENT.
- textarget describes the texture’s target, for example GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_POSITIVE_X, etc.
- texture is the texture object name; providing 0 unbinds the attachment.
- level selects the mipmap level of the texture to attach; 0 is the base level.
Usage: Bind the framebuffer, create and configure a texture, then call glFramebufferTexture2D with the appropriate attachment
Notes: The attached texture must be compatible with the framebuffer’s format and have matching dimensions. For