glFramebufferTexture2D Function

Syntax

GL_APICALL void GL_APIENTRY glFramebufferTexture2D(
     GLenum target,
     GLenum attachment,
     GLenum textarget,
     GLuint texture,
     GLint level
);

Arguments

Name Description
in target Target framebuffer
in attachment Attachment point
in textarget Target texture.
in texture Texture object
in level Mipmap level

Return Values

There is no return value.

Description

Attaches a texture to the current framebuffer.

You can render to attached textures.

You must specify a value of GL_FRAMEBUFFER for the target argument.

Specify a value of GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, or GL_DEPTH_STENCIL_ATTACHMENT for the attachment argument.

Set textarget to one of the following values.

GL_TEXTURE_2D2D texture
GL_TEXTURE_CUBE_MAP_NEGATIVE_XCube-map texture (face where x < 0)
GL_TEXTURE_CUBE_MAP_NEGATIVE_YCube-map texture (face where y < 0)
GL_TEXTURE_CUBE_MAP_NEGATIVE_ZCube-map texture (face where z < 0)
GL_TEXTURE_CUBE_MAP_POSITIVE_XCube-map texture (face where x > 0)
GL_TEXTURE_CUBE_MAP_POSITIVE_YCube-map texture (face where y > 0)
GL_TEXTURE_CUBE_MAP_POSITIVE_ZCube-map texture (face where z > 0)

Set texture to the texture object to attach. You can specify a texture allocated in main memory using NN_GX_MEM_FCRAM with glTexImage2D, but hardware specifications do not allow it to be cleared by the glClear function. Rendering to main memory makes it easy for bus conflicts to occur and is less efficient than using textures allocated in VRAM.

Specify 0 for level.

Only textures of the following formats can be attached to a depth attachment point.

Depth Buffer FormatDepth Buffer ContentCorresponding Texture Format (Texture Type)
GL_DEPTH24_STENCIL8_EXTR: 8-bit stencil value
G: 24-bit depth value, bits [23:16]
B: 24-bit depth value, bits [15:8]
A: 24-bit depth value, bits [7:0]
GL_RGBA (GL_UNSIGNED_BYTE), GL_RGBA_NATIVE_DMP (GL_UNSIGNED_BYTE)
GL_DEPTH_COMPONENT24_OESR: 24-bit depth value, bits [23:16]
G: 24-bit depth value, bits [15:8]
B: 24-bit depth value, bits [7:0]
GL_RGB (GL_UNSIGNED_BYTE), GL_RGB_NATIVE_DMP (GL_UNSIGNED_BYTE)
GL_DEPTH_COMPONENT16R: 16-bit depth value, bits [15:8]
G: 16-bit depth value, bits [7:0]
GL_HILO8_DMP (GL_UNSIGNED_BYTE), GL_HILO8_NATIVE_DMP (GL_UNSIGNED_BYTE)
Call this function with a value of GL_DEPTH_ATTACHMENT for the attachment argument to attach one of the above formats. The texture format RGBA values are used for other formats including the stencil. You can also call this function with a value of GL_DEPTH_STENCIL_ATTACHMENT for the attachment argument, but the end result is the same.

The following errors occur in this function.

GL_INVALID_ENUMThe target or textarget argument was set to an invalid value.
GL_INVALID_VALUEBoth texture and level are nonzero.
GL_INVALID_OPERATIONThe texture argument was set equal to a nonexistent texture object.
GL_INVALID_OPERATIONThe texture argument was bound to GL_TEXTURE_2D by glBindTexture but textarget is not GL_TEXTURE_2D.
GL_INVALID_OPERATIONThe texture argument was bound to GL_TEXTURE_CUBE_MAP by glBindTexture but textarget is not GL_TEXTURE_CUBE_MAP_XXX.

Revision History

2010/08/12
Explained support of depth attachment points. Explained deprecation of limits on where rendering target textures can be allocated. Deleted description of errors occurring only for POD.
2010/05/12
Fixed typos and added supplementary information on the placement of texture object data.
2010/01/07
Initial version.

CONFIDENTIAL