GLFramebuffer

A Framebuffer is a target for rendering, which includes one ore more color buffers, and an optional depth buffer. Color and depth buffers can be either a GLRenderbuffer, or a GLTexture, in which case the texture can be used as a texture input for another rendering pass.

Constructor

new L3D.GLFramebuffer(gl, colorTextures, depthTexture, stencil)

Creates a new frame buffer object.

Parameters
gl GLContext

The GLContext to create the framebuffer with.

colorTextures *
depthTexture *
stencil bool

Properties

The GLFramebuffer currently bound to the active GLContext

colorTexture GLTexture

The first bound color texture, which is usually the primary one.

Methods

bind()

Make the framebuffer active so all rendering will render to it.

blit(colorIndex, targetTexture, shader, uniforms)

Draw the framebuffer color texture to the screen (or current framebuffer)

Parameters
colorIndex int

The color texture to draw, 0 by default

targetTexture GLTexture

Optional texture to draw to, otherwise it will draw to the screen or active framebuffer.

shader GLShader

Optional shader to use.

uniforms Object

Optional uniforms for the shader.

destroy()

Free up GL memory used by the framebuffer.

setTextures(colorTextures, depthTexture, skipDisable)

Bind color and depth textures to the framebuffer.

Parameters
colorTextures *
depthTexture GLTexture
skipDisable bool

If true, the framebuffer won't be unbound after initialization, allowing it to continue to be used without having to rebind it.

unbind()

Unbind the framebuffer, switching back to the previous active framebuffer.

update(skipDisable)

Updates the framebuffer with the textures and buffers.

Parameters
skipDisable bool

If true, the framebuffer won't be unbound after updating, allowing it to continue to be used without having to rebind it.