Class: DoubleBufferedFbo

DoubleBufferedFbo(dc, texture1, texture2, width, height)

A DoubleBufferedFbo is typically used in offscreen rendering scenarios when the data from the previous frame is needed in the current frame. Using two framebuffers backed by two textures avoids syncronization between the CPU and GPU. Applications typically do not interact with this class.

Constructor

new DoubleBufferedFbo(dc, texture1, texture2, width, height)

Constructs a DoubleBufferedFbo.
Parameters:
Name Type Description
dc DrawContext The current draw context.
texture1 WebGLTexture The texture for the first framebuffer.
texture2 WebGLTexture The texture for the second framebuffer.
width Number The width of the framebuffers, in pixels.
height Number The height of the framebuffers, in pixels.
Source:
Throws:
If the specified DrawContext or textures are missing, or if the width or height is less than zero.
Type
ArgumentError

Members

fbo1 :WebGLFramebuffer

Type:
  • WebGLFramebuffer
Source:

(readonly) fbo1Complete :Boolean

Indicates if texture1 has been attached to the fbo1.
Type:
  • Boolean
Source:

fbo2 :WebGLFramebuffer

Type:
  • WebGLFramebuffer
Source:

(readonly) fbo2Complete :Boolean

Indicates if texture2 has been attached to the fbo2.
Type:
  • Boolean
Source:

(readonly) height :Number

The height of the framebuffers, in pixels.
Type:
  • Number
Source:

isCleared :Boolean

Indicates if both framebuffers have been cleared using the clearFbo method. Calling code must set this flag to false after rendering in one the the framebuffers.
Type:
  • Boolean
Source:

(readonly) primary :Number

Indicates which of the two framebuffers and textures is the primary one.
Type:
  • Number
Source:

(readonly) size :Number

Indicates the size of the framebuffers, in bytes.
Type:
  • Number
Source:

(readonly) texture1 :WebGLTexture

Type:
  • WebGLTexture
Source:

(readonly) texture2 :WebGLTexture

Type:
  • WebGLTexture
Source:

(readonly) width :Number

The width of the framebuffers, in pixels.
Type:
  • Number
Source:

Methods

bind(dc)

Binds the primary texture in the current WebGL graphics context.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Source:

bindFbo(dc)

Binds the primary fbo in the current WebGL graphics context.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Source:

clearFbo(dc)

Clears both frambuffers using the gl.clear command. Calling code must make sure to rebind to the previously used framebuffer and set the propper viewport.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Source:

dispose(gl)

Disposes of the WebGL textures and framebuffers.
Parameters:
Name Type Description
gl WebGLRenderingContext
Source:

ensureFboComplete(dc)

Ensures that the framebuffer has a texture attached.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Source:

getPrimaryFbo() → {WebGLFramebuffer}

Gets the primary framebuffer.
Source:
Returns:
Type
WebGLFramebuffer

getPrimaryTexture() → {WebGLTexture}

Gets the primary texture.
Source:
Returns:
Type
WebGLTexture

getSecondaryFbo() → {WebGLFramebuffer}

Gets the secondary framebuffer.
Source:
Returns:
Type
WebGLFramebuffer

getSecondaryTexture() → {WebGLTexture}

Gets the secondary texture.
Source:
Returns:
Type
WebGLTexture

swap()

Swaps the primary and secondary framebuffer and texture.
Source: