This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The WebGLRenderingContext.bindFramebuffer() method of the WebGL API binds to the specified target the provided WebGLFramebuffer, or, if the framebuffer argument is null, the default WebGLFramebuffer, which is associated with the canvas rendering context.
bindFramebuffer(target, framebuffer)
targetA GLenum specifying the binding point (target). Possible values:
gl.FRAMEBUFFERCollection buffer data storage of color, alpha, depth and stencil buffers used as both a destination for drawing and as a source for reading (see below).
When using a WebGL 2 context, the following values are available additionally:
gl.DRAW_FRAMEBUFFERUsed as a destination for drawing operations such as gl.draw*, gl.clear* and gl.blitFramebuffer.
gl.READ_FRAMEBUFFERUsed as a source for reading operations such as gl.readPixels and gl.blitFramebuffer.
framebufferA WebGLFramebuffer object to bind, or null for binding the HTMLCanvasElement or OffscreenCanvas object associated with the rendering context.
None (undefined).
A gl.INVALID_ENUM error is thrown if target is not gl.FRAMEBUFFER, gl.DRAW_FRAMEBUFFER, or gl.READ_FRAMEBUFFER.
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
To check the current frame buffer binding, query the FRAMEBUFFER_BINDING constant.
gl.getParameter(gl.FRAMEBUFFER_BINDING);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
bindFramebuffer |
9 | 12 | 4 | 12 | 5.1 | 25 | 4 | 12 | 8 | 1.5 | 4.4.3 | 8 |
WebGLRenderingContext.createFramebuffer()WebGLRenderingContext.deleteFramebuffer()WebGLRenderingContext.isFramebuffer()WebGLBuffer, WebGLRenderbuffer
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bindFramebuffer