glFramebufferTexture
Attaches a whole texture to a framebuffer; a cubemap or array texture is attached with all its layers.
Signature
void glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);
How it works
Unlike glFramebufferTexture2D there is no texture-target argument. For a plain 2D texture the two are the same. For a cubemap or array texture this makes a layered attachment: one draw can reach every face, and a geometry shader chooses which by writing gl_Layer.
That is how an omnidirectional (point-light) shadow map is drawn in one pass: the geometry shader emits each triangle six times, once per cube face.
Parameters
GL_FRAMEBUFFER, GL_DRAW_FRAMEBUFFER or GL_READ_FRAMEBUFFER.
GL_COLOR_ATTACHMENTi, GL_DEPTH_ATTACHMENT…
The texture, or 0 to detach.
Mip level, usually 0.
Tips & pitfalls
If one attachment is layered, all of them must be, or the framebuffer is incomplete (GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS).
Example
1// point-light shadows: depth cubemap, all 6 faces in one pass
2glBindFramebuffer(GL_FRAMEBUFFER, depthFbo);
3glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthCubemap, 0);
4glDrawBuffer(GL_NONE);
5glReadBuffer(GL_NONE);