Skip to main content

Class: RenderTarget

Defined in: rendering/render-target.ts:16

An off-screen render destination: a framebuffer with a single color texture attachment. Used to render a scene (or a pass over a previous render target's output) into a texture instead of directly onto the canvas.

Constructors​

Constructor​

new RenderTarget(gl, width, height, format?): RenderTarget

Defined in: rendering/render-target.ts:54

Creates a new RenderTarget.

Parameters​

gl​

WebGL2RenderingContext

The WebGL2 rendering context.

width​

number

The render target width in pixels.

height​

number

The render target height in pixels.

format?​

RENDER_TARGET_FORMAT_KEYS = RENDER_TARGET_FORMAT.ldr

The requested color storage format. Defaults to RENDER_TARGET_FORMAT.ldr. RENDER_TARGET_FORMAT.hdr falls back to ldr if the context lacks EXT_color_buffer_float (see resolveRenderTargetFormat).

Returns​

RenderTarget

Throws​

An error if the framebuffer is not complete after attaching the color texture.

Properties​

colorTexture​

colorTexture: WebGLTexture

Defined in: rendering/render-target.ts:31

The color texture attached to the framebuffer, readable by later passes.


format​

readonly format: RENDER_TARGET_FORMAT_KEYS

Defined in: rendering/render-target.ts:26

The color texture's storage format, resolved once at construction. See RENDER_TARGET_FORMAT.


framebuffer​

readonly framebuffer: WebGLFramebuffer

Defined in: rendering/render-target.ts:20

The framebuffer this target renders into.


height​

height: number

Defined in: rendering/render-target.ts:41

The render target height in pixels.


width​

width: number

Defined in: rendering/render-target.ts:36

The render target width in pixels.

Methods​

dispose()​

dispose(gl): void

Defined in: rendering/render-target.ts:98

Deletes the framebuffer and color texture, freeing their GPU resources.

Parameters​

gl​

WebGL2RenderingContext

The WebGL2 rendering context.

Returns​

void


resize()​

resize(gl, width, height): void

Defined in: rendering/render-target.ts:76

Resizes the render target, recreating its color texture at the new dimensions.

Parameters​

gl​

WebGL2RenderingContext

The WebGL2 rendering context.

width​

number

The new render target width in pixels.

height​

number

The new render target height in pixels.

Returns​

void

Throws​

An error if the framebuffer is not complete after reattaching the color texture.