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

: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:

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({ colorTexture : texture });
// ...
framebuffer = framebuffer.destroy();
// texture is also destroyed.
See:

Returns the color renderbuffer attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The color renderbuffer attached to this framebuffer.

Returns the color texture attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The color texture attached to this framebuffer.

Returns the depth renderbuffer attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The depth renderbuffer attached to this framebuffer.

Returns the depth-stencil renderbuffer attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The depth-stencil renderbuffer attached to this framebuffer.

Returns the depth-stencil texture attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The depth-stencil texture attached to this framebuffer.

Returns the depth texture attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The depth texture attached to this framebuffer.

Returns the stencil renderbuffer attached to this framebuffer.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Texture The stencil renderbuffer attached to this framebuffer.

Returns 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.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.
Returns:
Boolean Returns true if the framebuffer has a depth attachment; otherwise, false.

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:

Prefer Framebuffer#setColorTexture.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.

Attaches a texture to the color attachment point. When this framebuffer is passed to a draw or clear call, the texture is the target of color output, e.g., gl_FragColor.

Parameters:
Name Type Description
The Texture texture to attach. undefined dettaches the current texture.
Throws:
  • DeveloperError : The color-texture pixel-format must be a color format.
  • DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.

Prefer Framebuffer#setDepthTexture.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.

Prefer Framebuffer#setDepthStencilTexture.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.

Attaches a texture to the depth-stencil attachment point. When this framebuffer is passed to a draw or clear call, the texture is the target of depth and stencil output.

Parameters:
Name Type Description
The Texture texture to attach. undefined dettaches the current texture.
Throws:
  • DeveloperError : The depth-stencil-texture pixel-format must be DEPTH_STENCIL.
  • DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.

Attaches a texture to the depth attachment point. When this framebuffer is passed to a draw or clear call, the texture is the target of depth output.

Parameters:
Name Type Description
The Texture texture to attach. undefined dettaches the current texture.
Throws:
  • DeveloperError : The depth-texture pixel-format must be DEPTH_COMPONENT.
  • DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.

Prefer Framebuffer#setDepthStencilTexture.

Throws:
DeveloperError : This framebuffer was destroyed, i.e., destroy() was called.