Renderer · function

createPassAttachment

Build one. Called from a pass's init, or from its prepare when the size has changed.

Explained in Hello world.

function createPassAttachment(device: PassDevice, options: PassAttachmentOptions): PassTarget
import { createPassAttachment } from '@driftengine/core';

Parameters

ParameterTypeDescription
devicePassDevice
optionsPassAttachmentOptions

In depth

Restores the default framebuffer on WebGL2, rather than whatever was bound before. Both points where a pass may call this — init, outside a frame, and prepare, whose contract is that the default framebuffer is bound on entry and on exit — have the default bound, so restoring to it is restoring what was there. Reading the binding back to restore it exactly would be a synchronous driver query in return for covering a case the contract forbids.

Fails fast on a size that cannot work, which is the init-time rule: a zero-sized attachment is a framebuffer that is never complete, and a driver reports that as a black draw rather than an error.