Skip to main content

Framebuffer

A texture-backed WebGL framebuffer that is both a render destination and a texture source.

Draw into it by passing it as the destination of a ShaderPass.draw (or any consumer of Framebuffer.glFramebuffer), sample from it by passing it as a source (or reading Framebuffer.texture). There is no implicit bind/unbind protocol to sequence.

Contents are premultiplied alpha, matching the rest of the Excalibur WebGL pipeline.

Hierarchy

Index

Constructors

constructor

Properties

publicreadonlybufferFormat

bufferFormat: number

Format compatible with the canvas drawing buffer, needed for Framebuffer.blitToScreen

publicreadonlyfiltering

filtering: ImageFiltering

publicreadonlytransparency

transparency: boolean

publicreadonlywrapping

Accessors

publicglFramebuffer

  • get glFramebuffer(): WebGLFramebuffer
  • The framebuffer to bind when drawing into this framebuffer.

    On a MultisampleFramebuffer this is the multisampled renderbuffer framebuffer.


    Returns WebGLFramebuffer

publicheight

  • get height(): number
  • Returns number

publictexelSize

  • get texelSize(): [texelWidth: number, texelHeight: number]
  • [1 / width, 1 / height], useful for passing to shaders that sample neighboring texels (blurs etc.)


    Returns [texelWidth: number, texelHeight: number]

publictexture

  • get texture(): WebGLTexture
  • The color texture backing this framebuffer, for sampling as a source.

    On a MultisampleFramebuffer reading this resolves the MSAA renderbuffer first.


    Returns WebGLTexture

publicwidth

  • get width(): number
  • Returns number

Methods

publicblitToScreen

  • blitToScreen(): void
  • Blits the (resolved) contents 1:1 to the canvas drawing buffer


    Returns void

publicclear

  • clear(color?: Color): void
  • Clears the framebuffer to the provided color (transparent black by default)

    Leaves this framebuffer bound


    Parameters

    Returns void

publiccopyToTexture

  • copyToTexture(texture: WebGLTexture): void
  • Copies the current (resolved) contents into the provided texture, which is reallocated at this framebuffer's dimensions


    Parameters

    • texture: WebGLTexture

    Returns void

publicdispose

  • dispose(): void
  • Deletes the GL resources owned by this framebuffer, it cannot be used afterwards


    Returns void

publicresize

  • resize(width: number, height: number): void
  • Resize the framebuffer, contents are discarded


    Parameters

    • width: number
    • height: number

    Returns void