Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BlitPass

This rendering pass blits the color attachment of a given rgba-framebuffer into the target buffer provided on frame. For rendering, a direct blit is used. However, if this is not supported, a textured, screen-aligned triangle is used for blitting as fallback.

The blit pass can be used as follows:

this._blitPass = new BlitPass(this._context);
this._blitPass.initialize();

this._blitPass.readBuffer = gl2facade.COLOR_ATTACHMENT0;
// this._blitPass.srcBounds = vec4.fromValues(0, 0, this._sourceSize[0], this._sourceSize[1]);
this._blitPass.filter = gl.LINEAR;
this._blitPass.target = this._defaultFBO;
this._blitPass.drawBuffer = gl.BACK;

this.blitPass.framebuffer = this.intermediateFBO;
// this.blitPass.dstBounds = vec4.fromValues(dstX0, dstY0, dstX1, dstY1);
this.blitPass.frame();

Hierarchy

Index

Constructors

constructor

Properties

Protected _context

_context: Context

Read-only access to the objects context, used to get context information and WebGL API access.

Protected _drawBuffer

_drawBuffer: number

Protected _dstBounds

_dstBounds: undefined | vec4
see

dstBounds

Protected _enforceProgramBlit

_enforceProgramBlit: boolean = false
see

{@link forceProgramBlit}

Protected _filter

_filter: number
see

filter

Protected _framebuffer

_framebuffer: Framebuffer

Protected _ndcTriangle

_ndcTriangle: NdcFillingTriangle

Geometry used to draw on. This is not provided by default to allow for geometry sharing. If no triangle is given, the ndc triangle will be created and managed internally.

Protected _ndcTriangleShared

_ndcTriangleShared: boolean = false

Tracks ownership of the ndc-filling triangle.

Protected _program

_program: Program

Protected _readBuffer

_readBuffer: number

Protected _srcBounds

_srcBounds: undefined | vec4
see

srcBounds

Protected _target

_target: Framebuffer
see

target

Protected _uDstBounds

_uDstBounds: WebGLUniformLocation

Uniform for passing the destination bounds to blit.

Protected _uNearest

_uNearest: WebGLUniformLocation

Uniform for passing the filter to blit: true for nearest, false otherwise (linear).

Protected _uSrcBounds

_uSrcBounds: WebGLUniformLocation

Uniform for passing the source bounds to blit.

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.

Type declaration

    • (): void
    • Returns void

Protected assertUninitialized

assertUninitialized: () => void = ...

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.

Type declaration

    • (): void
    • Returns void

Accessors

drawBuffer

  • set drawBuffer(drawBuffer: number): void
  • The draw buffer to blit to (currently, this is expected to refer to a texture attachment of this._target or gl.BACK). Please note that this will be ignored if WebGL 1 is used without a WEBGL_draw_buffer extension. Furthermore, if the drawBuffer is gl.BACK, a DefaultBuffer is expected as target.

    Parameters

    • drawBuffer: number

      GLenum that specifies the draw buffer.

    Returns void

dstBounds

  • set dstBounds(bounds: undefined | vec4): void
  • Specify the bounds of the destination rectangle within the write buffer of the write framebuffer.

    Parameters

    • bounds: undefined | vec4

      [srcX0, srcY0, srcX1, srcY1] as used in glBlitFramebuffer. If bounds is undefined, the full size of the destination (target) buffer will be used.

    Returns void

enforceProgramBlit

  • set enforceProgramBlit(enforce: boolean): void
  • Specify whether or not experimental WebGL blit can be used if available.

    Parameters

    • enforce: boolean

      If true, program based blit instead of WebGL experimental blit function will be used.

    Returns void

filter

  • set filter(filter: number): void
  • Specifies the interpolation to be applied if the image is stretched. Must be GL_NEAREST or GL_LINEAR.

    Parameters

    • filter: number

    Returns void

framebuffer

initialized

  • get initialized(): boolean
  • Property getter for readonly access to the initialization status of an initializable instance.

    Returns boolean

readBuffer

  • set readBuffer(readBuffer: number): void
  • The read buffer to blit from (currently, this is expected to refer to a texture attachment of this._framebuffer).

    Parameters

    • readBuffer: number

      GLenum that is to be queried from the FBO.

    Returns void

srcBounds

  • set srcBounds(bounds: undefined | vec4): void
  • Specify the bounds of the source rectangle within the read buffer of the read framebuffer.

    Parameters

    • bounds: undefined | vec4

      [srcX0, srcY0, srcX1, srcY1] as used in glBlitFramebuffer. If bounds is undefined, the full size of the source buffer (framebuffer) will be used.

    Returns void

target

  • Framebuffer to blit the given framebuffer (@see framebuffer} into.

    Parameters

    Returns void

Methods

Protected createProgram

  • createProgram(): boolean
  • Used to create (on-demand) the blit program for program based blitting. This function can be specialized, e.g., for creating custom blit passes such as the DebugPass DebugPass. This method assumes the program to be undefined.

    Returns boolean

frame

  • frame(): void
  • A blit frame either blits or draws the color attachment of the given framebuffer to the target framebuffer. For program based/indirect blit a viewport filling area, i.e., a screen-aligned triangle is used.

    Returns void

Private functionBlit

  • functionBlit(): void
  • Uses direct blit via glBlitFramebuffer for blitting a single read buffer into the given target's draw buffer.

    Returns void

initialize

  • Specializes this pass's initialization. This pass either requires blitFramebuffer support or creates screen- aligned triangle geometry and a single program. All attribute and dynamic uniform locations are cached.

    Parameters

    • Optional ndcTriangle: NdcFillingTriangle

      If specified, assumed to be used as shared geometry. If none is specified, a ndc-filling triangle will be created internally.

    Returns boolean

Private programBlit

  • programBlit(): void
  • Uses indirect blit by drawing a textured, screen-aligned triangle into the given target framebuffer.

    Returns void

uninitialize

  • uninitialize(): void
  • Specializes this pass's uninitialization. Program and geometry resources are released (if allocated). Cached uniform and attribute locations are invalidated.

    Returns void

Static Protected Readonly assertInitializedFalse

Static Protected Readonly assertUninitializedFalse

Static assert_initialized

  • assert_initialized(): MethodDecorator

Static assert_uninitialized

  • assert_uninitialized(): MethodDecorator

Static discard

  • discard(): MethodDecorator
  • Method decorator for discarding of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be discarded, 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

Static initialize

  • initialize(): MethodDecorator
  • 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 uninitialize

  • uninitialize(): MethodDecorator
  • 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