docs.rodeo

MDN Web Docs mirror

WebGLRenderingContext: bindFramebuffer() method

{{APIRef("WebGL")}} {{AvailableInWorkers}} 

The WebGLRenderingContext.bindFramebuffer() method of the WebGL API binds to the specified target the provided {{domxref("WebGLFramebuffer")}} , or, if the framebuffer argument is null, the default {{domxref("WebGLFramebuffer")}} , which is associated with the canvas rendering context.

Syntax

bindFramebuffer(target, framebuffer)

Parameters

Return value

None ({{jsxref("undefined")}} ).

Exceptions

A gl.INVALID_ENUM error is thrown if target is not gl.FRAMEBUFFER, gl.DRAW_FRAMEBUFFER, or gl.READ_FRAMEBUFFER.

Examples

Binding a frame buffer

const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();

gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);

Getting current bindings

To check the current frame buffer binding, query the FRAMEBUFFER_BINDING constant.

gl.getParameter(gl.FRAMEBUFFER_BINDING);

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN