Skip to content
bg2 engine

FrameBuffer

The FrameBuffer class manages the main display frame buffer for rendering to-screen. It provides simple clear operations for the color and depth buffers.

Access through renderer.frameBuffer:

const fb = myRenderer.frameBuffer;
fb.clear(); // Clear color and depth buffers
private constructor(renderer: Renderer)

The frame buffer is created automatically when first accessed via renderer.frameBuffer (lazy instantiation).

Clears the color and depth buffers (default behavior, same as clearAll()):

fb.clear(); // Equivalent to clear({ color: true, depth: true })

clearColor() — Clear Color Only (with Depth)

Section titled “clearColor() — Clear Color Only (with Depth)”

Clears the color buffer, leaving the depth buffer untouched:

fb.clearColor(); // Equivalent to clear({ color: true, depth: false })

clearDepth() — Clear Depth Only (with Color)

Section titled “clearDepth() — Clear Depth Only (with Color)”

Clears both the color and depth buffers:

fb.clearDepth(): void // Clear everything (color + depth)

Clears the stencil buffer:

fb.clearStencil(); // Clear just the stencil buffer