Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DefaultFramebuffer

Default framebuffer with framebuffer interface. It is intended for use as default buffer binding and enables lazy target size reconfiguration of stages.

this._someStage.frame(this._nullFBO, frameNumber, multiFrameNumber);

Note that this buffer does query its size from the current context's canvas.

Hierarchy

Implements

Index

Constructors

constructor

  • Object constructor, requires a context and a valid identifier.

    Parameters

    • context: Context

      Valid context to create the object for.

    • Optional identifier: undefined | string

      Meaningful name for identification of this instance.

    Returns DefaultFramebuffer

Properties

Protected _buffersByAttachment

_buffersByAttachment: Map<number, Renderbuffer> = new Map<GLenum, Renderbuffer>()

Access to all attached renderbuffer objects.

Protected _clearColors

_clearColors: Array<GLclampf4>

Protected _clearDepth

_clearDepth: GLfloat

RGBA color, depth value, or stencil value used for clearing the associated buffer.

Protected _clearStencil

_clearStencil: GLint

Protected _colorClearQueue

_colorClearQueue: number[] = new Array<GLint>()

Queue of all draw buffers that are to be cleared on clear.

Protected _context

_context: Context
see

context

Protected _drawBuffers

_drawBuffers: number[] = new Array<GLenum>()

Protected _drawBuffersChanged

_drawBuffersChanged: boolean = false

Protected _identifier

_identifier: string

Protected _object

_object: WebGLFramebuffer | undefined
see

object

Protected _referenceCount

_referenceCount: number = 0

Number of references to this object. If at least a single reference was counted, this object can neither be initialized (and thus created) nor uninitialized (and thus deleted). The reference count is controlled via ref() and unref() functions.

Protected _texturesByAttachment

_texturesByAttachment: Map<number, Texture2D> = new Map<GLenum, Texture2D>()

Access to all attached texture objects.

Protected _valid

_valid: boolean = false
see

valid

clear

clear: function

Depending on the webgl version and provided bitmask, clears attachments of the framebuffer. Note that this function is set/unset to gl1Clear or gl2Clear on initialization/uninitialization.

param

Bitmask specifying which bits are to be cleared (and thereby which attachments).

param

Allows to skip binding the framebuffer (e.g., when binding is handled outside).

param

Allows to skip unbinding the framebuffer (e.g., when binding is handled outside).

param

allows to specify a specific queue of color attachments to be cleared. The webgl1 implementation ignores this parameter. If no parameter is given, the webgl2 implementation clears all color attachments.

Type declaration

    • (mask: GLbitfield, bind?: undefined | false | true, unbind?: undefined | false | true, colorClearQueue?: Array<GLint>): void
    • Parameters

      • mask: GLbitfield
      • Optional bind: undefined | false | true
      • Optional unbind: undefined | false | true
      • Optional colorClearQueue: Array<GLint>

      Returns void

Static DEFAULT_FRAMEBUFFER

DEFAULT_FRAMEBUFFER: undefined = undefined

Default framebuffer, e.g., used for unbind.

Accessors

context

drawBuffers

  • get drawBuffers(): Array<GLenum>
  • set drawBuffers(attachments: Array<GLenum>): void

height

  • get height(): GLsizei

identifier

  • get identifier(): string
  • Every GPU asset that allocates memory should provide a human readable identifier for GPU allocation tracking and debugging purposes. Please note that the identifier might changed on initialization due to the generation and assignment of a unique identifier.

    Returns string

    • This assets identifier used for gpu allocation tracking and debugging.

initialized

  • get initialized(): boolean

object

  • get object(): WebGLFramebuffer

size

valid

  • get valid(): boolean
  • Cached object status used to derive validity when initialized.

    Returns boolean

    • True if the object status is complete, false otherwise.

width

  • get width(): GLsizei

Methods

Protected assertInitialized

  • assertInitialized(): void
  • Asserts the objects initialization status to be true. Note that the implementation is cached and forwarded to either an empty function when initialized and to an acutal assert(false) otherwise.

    Returns void

Protected assertUninitialized

  • assertUninitialized(): undefined
  • Asserts the objects initialization status to be false. Note that the implementation is cached and forwarded to either an empty function when uninitialized and to an acutal assert(false) otherwise.

    Returns undefined

bind

  • bind(target?: GLenum): void
  • override

    Binds the default framebuffer object to the provided target.

    Parameters

    • Default value target: GLenum = this.context.gl.FRAMEBUFFER

      Specifying the binding point (target).

    Returns void

clearColor

  • override

    Sets the clear color used for clearing the default color buffer. In order to have transparency working, the canvas needs to have the alpha attribute enabled. This stage also supports premultiplied alpha, which is applied automatically when the context's premultipliedAlpha attribute is set.

    Parameters

    Returns void

clearDepth

  • clearDepth(depth: GLfloat): void

clearStencil

  • clearStencil(stencil: GLint): void

Protected create

  • create(): WebGLFramebuffer | undefined

Protected delete

  • delete(): void

Protected es2Clear

  • es2Clear(mask: GLbitfield, bind?: boolean, unbind?: boolean): void
  • WebGL1 implementation for clearing framebuffer attachments.

    Parameters

    • mask: GLbitfield

      A GLbitfield bitwise OR mask that indicates the buffers to be cleared.

    • Default value bind: boolean = true

      Allows to skip binding the framebuffer (e.g., when binding is handled outside).

    • Default value unbind: boolean = true

      Allows to skip unbinding the framebuffer (e.g., when binding is handled outside).

    Returns void

Protected es3Clear

  • es3Clear(mask: GLbitfield, bind?: boolean, unbind?: boolean, colorClearQueue?: Array<GLint>): void
  • WebGL2 implementation for clearing framebuffer attachments.

    Parameters

    • mask: GLbitfield

      A GLbitfield bitwise OR mask that indicates the buffers to be cleared.

    • Default value bind: boolean = true

      Allows to skip binding the framebuffer (e.g., when binding is handled outside).

    • Default value unbind: boolean = true

      Allows to skip unbinding the framebuffer (e.g., when binding is handled outside).

    • Optional colorClearQueue: Array<GLint>

      Allows to specify a specific queue of color attachments to be cleared. If no parameter is given, the webgl2 implementation clears all color attachments.

    Returns void

Protected hasAttachment

  • hasAttachment(attachment: GLenum): boolean

initialize

  • initialize(...args: any[]): boolean
  • override

    Ensure that an object handle is created at the point of initialization. When overriding this function super.initialize() has to be invoked immediately/first. Please note that initialization of invalid object raises an assertion in order to prevent further actions without a valid WebGL object. After object creation the valid property is expected to be set accordingly.

    Parameters

    • Rest ...args: any[]

    Returns boolean

ref

  • ref(): void

resize

  • resize(): void

texture

  • texture(attachment: GLenum): Texture2D | undefined
  • Access to attached textures, identified by a valid framebuffer attachment.

    Parameters

    • attachment: GLenum

      The attachment to request the texture object of.

    Returns Texture2D | undefined

    • A texture object if one exists for the given attachment, otherwise undefined.

unbind

  • unbind(target?: GLenum): void
  • Binds the default back buffer as framebuffer to the provided target.

    Parameters

    • Default value target: GLenum = this.context.gl.FRAMEBUFFER

      Specifying the binding point (target).

    Returns void

uninitialize

  • uninitialize(): void
  • override

    Ensure that an object handle is deleted, invalidated, and its allocated GPU resources are set to zero. When overriding this function super.uninitialize() has to be invoked last/at the end. Note that an object cannot be uninitialized if it is referenced (reference count > 0).

    Returns void

unref

  • unref(): void

Static Protected assertInitializedFalse

Static Protected assertUninitializedFalse

Static assert_initialized

Static assert_uninitialized

Static initialize

  • Method decorator for initialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be initialized, invokes its initialization with arbitrary number of parameters, and sets the initialization status to the initialization success (either false or true). In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to either a static, always-failing assert or an empty/undefined function.

    Returns MethodDecorator

Static Protected statusString

  • statusString(context: Context, status: GLenum): string
  • Returns a string describing the given status of a framebuffer object.

    Parameters

    • context: Context

      Context for valid GLenums.

    • status: GLenum

      A framebuffer's status.

    Returns string

Static uninitialize

  • Method decorator for uninitialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be uninitialized, invokes its uninitialization, and falsifies the initialization status. In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to a static, always-failing assert and an empty/undefined function respectively.

    Returns MethodDecorator