Atlaslog
Atlaslog / luma.gl / API reference / Framebuffer
luma.gl · API reference

Framebuffer

Quick answer

Framebuffer combines color and depth attachments into an offscreen render target whose pixels stay in textures for later sampling or readback. Create it with device.createFramebuffer({width, height, colorAttachments, depthStencilAttachment}), then pass it to beginRenderPass to draw offscreen. Recreate it whenever the canvas or attachment size changes.

Last verified 2026-11-03 · luma.gl 9.4 · Cite this page
device. createFramebuffer ({ width, height, colorAttachments, depthStencilAttachment }) → Framebuffer
Key points
Example
const color = device.createTexture({
  width: 512,
  height: 512,
  format: 'rgba8unorm',
  usage: Texture.SAMPLE | Texture.RENDER | Texture.COPY_DST,
  sampler: { minFilter: 'linear', magFilter: 'linear' }
});

const depth = device.createTexture({
  width: 512,
  height: 512,
  format: device.preferredDepthFormat,
  usage: Texture.RENDER
});

const fbo = device.createFramebuffer({
  width: 512,
  height: 512,
  colorAttachments: [color],
  depthStencilAttachment: depth
});

const pass = device.beginRenderPass({
  framebuffer: fbo,
  clearColor: [0.04, 0.06, 0.09, 1]
});

pass.setPipeline(pipeline);
pass.setVertexArray(vertexArray);
pass.draw({ vertexCount: 3 });
pass.end();
device.submit();
const post = device.createRenderPipeline({
  vs: postVS,
  fs: postFS,
  topology: 'triangle-list',
  bufferLayout: [
    { name: 'positions', stepMode: 'vertex', format: 'float32x2' }
  ]
});

const screen = device.beginRenderPass({ clearColor: [0, 0, 0, 1] });
screen.setPipeline(post);
screen.setVertexArray(quadArray);
screen.setBindings({ uScene: color });
screen.draw({ vertexCount: 6 });
screen.end();
device.submit();
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Framebuffer. https://www.jingweizhi.com/en/lumagl/api/framebuffer.html (accessed 2026-11-03).