WebGLRenderingContext: framebufferTexture2D() method

Note: This feature is available in Web Workers.

The WebGLRenderingContext.framebufferTexture2D() method of the WebGL API attaches a texture to a WebGLFramebuffer.

Syntax

js
framebufferTexture2D(target, attachment, textarget, texture, level)

Parameters

target

A GLenum specifying the binding point (target). Possible values:

gl.FRAMEBUFFER

Collection buffer data storage of color, alpha, depth and stencil buffers used to render an image.

When using a WebGL 2 context, the following values are available additionally:

gl.DRAW_FRAMEBUFFER

Used as a destination for drawing, rendering, clearing, and writing operations.

gl.READ_FRAMEBUFFER

Used as a source for reading operations.

When binding, gl.FRAMEBUFFER sets both the gl.DRAW_FRAMEBUFFER and gl.READ_FRAMEBUFFER binding points. When referencing, gl.FRAMEBUFFER refers to the gl.DRAW_FRAMEBUFFER binding

attachment

A GLenum specifying the attachment point for the texture. Possible values:

When using a WebGL 2 context, the following values are available additionally:

When using the WEBGL_draw_buffers extension:

When using the WEBGL_depth_texture extension:

textarget

A GLenum specifying the texture target. Possible values:

texture

A WebGLTexture object whose image to attach.

level

A GLint specifying the mipmap level of the texture image to be attached. Must be 0.

Return value

None (undefined).

Exceptions

Examples

js
gl.framebufferTexture2D(
  gl.FRAMEBUFFER,
  gl.COLOR_ATTACHMENT0,
  gl.TEXTURE_2D,
  texture,
  0,
);

Specifications

See also