Framebuffer

Framebuffer

new

A framebuffer is a target for draw and clear calls. It can contain color, depth, and stencil attachments that are written to in response to these calls. If the attachments are textures, they can be read in later rendering passes.

See:
Source:

Members

:Texture

The depth-stencil renderbuffer attached to this framebuffer.

:Texture

The depth-stencil texture attached to this framebuffer.

:Texture

The depth texture attached to this framebuffer.

:Boolean

When true, the framebuffer owns its attachments so they will be destroyed when Framebuffer#destroy is called or when a new attachment is assigned to an attachment point.
Default Value:
  • true
See:

:Boolean

True if the framebuffer has a depth attachment. Depth attachments include depth and depth-stencil textures, and depth and depth-stencil renderbuffers. When rendering to a framebuffer, a depth attachment is required for the depth test to have effect.

:Number

The number of color textures or renderbuffers attached to this framebuffer.

:Number

The status of the framebuffer. If the status is not WebGLRenderingContext.COMPLETE, a DeveloperError will be thrown when attempting to render to the framebuffer.

:Texture

The stencil renderbuffer attached to this framebuffer.

Methods

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Framebuffer attachments are only destoryed if the framebuffer owns them, i.e., destroyAttachments is true.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Example
var texture = context.createTexture2D({ width : 1, height : 1 });
framebuffer = context.createFramebuffer({ colorTextures : [texture] });
// ...
framebuffer = framebuffer.destroy();
// texture is also destroyed.
See:

Returns a color renderbuffer attached to this framebuffer.

Parameters:
Name Type Description
index Number The index of the color renderbuffer attachment.
Throws:
  • DeveloperError : index is required, must be greater than or equal to zero and must be less than the number of color attachments.
  • DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The color renderbuffer attached to this framebuffer.

Returns a color texture attached to this framebuffer.

Parameters:
Name Type Description
index Number The index of the color texture attachment.
Throws:
  • DeveloperError : index is required, must be greater than or equal to zero and must be less than the number of color attachments.
  • DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The color texture attached to this framebuffer.

Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.

Returns:
Boolean True if this object was destroyed; otherwise, false.
See: