Framebuffer

new Cesium.Framebuffer(options)

Creates a framebuffer with optional initial color, depth, and stencil attachments. Framebuffers are used for render-to-texture effects; they allow us to render to textures in one pass, and read from it in a later pass.
Name Type Description
options Object The initial framebuffer attachments as shown in the example below. context is required. The possible properties are colorTextures, colorRenderbuffers, depthTexture, depthRenderbuffer, stencilRenderbuffer, depthStencilTexture, and depthStencilRenderbuffer.
Throws:
  • DeveloperError : Cannot have both color texture and color renderbuffer attachments.
  • DeveloperError : Cannot have both a depth texture and depth renderbuffer attachment.
  • DeveloperError : Cannot have both a depth-stencil texture and depth-stencil renderbuffer attachment.
  • DeveloperError : Cannot have both a depth and depth-stencil renderbuffer.
  • DeveloperError : Cannot have both a stencil and depth-stencil renderbuffer.
  • DeveloperError : Cannot have both a depth and stencil renderbuffer.
  • DeveloperError : The color-texture pixel-format must be a color format.
  • DeveloperError : The depth-texture pixel-format must be DEPTH_COMPONENT.
  • DeveloperError : The depth-stencil-texture pixel-format must be DEPTH_STENCIL.
  • DeveloperError : The number of color attachments exceeds the number supported.
Example:
// Create a framebuffer with color and depth texture attachments.
var width = context.canvas.clientWidth;
var height = context.canvas.clientHeight;
var framebuffer = new Framebuffer({
  context : context,
  colorTextures : [new Texture({
    context : context,
    width : width,
    height : height,
    pixelFormat : PixelFormat.RGBA
  })],
  depthTexture : new Texture({
    context : context,
    width : width,
    height : height,
    pixelFormat : PixelFormat.DEPTH_COMPONENT,
    pixelDatatype : PixelDatatype.UNSIGNED_SHORT
  })
});

Members

destroyAttachments : 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:
  • Framebuffer#destroy

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

status : Number

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