Web/API/WEBGL draw buffers/drawBuffersWEBGL

From Get docs


The WEBGL_draw_buffers.drawBuffersWEBGL() method is part of the WebGL API and allows you to define the draw buffers to which all fragment colors are written.

This method is part of the WEBGL_draw_buffers extension.

Note: When using WebGL2, this method is available as gl.drawBuffers() by default and the constants are named gl.COLOR_ATTACHMENT1 etc. without the "WEBGL" suffix.


Syntax

void gl.getExtension('WEBGL_draw_buffers').drawBuffersWEBGL(buffers);

Parameters

buffers
An Array of GLenum constants defining drawing buffers. Possible values:
gl.NONE
  • The fragment shader is not written to any color buffer.
  • gl.BACK: The fragment shader is written to the back color buffer.
  • ext.COLOR_ATTACHMENT0_WEBGL The fragment shader is written the the nth color attachment of the framebuffer.
  • ext.COLOR_ATTACHMENT1_WEBGL
  • ext.COLOR_ATTACHMENT2_WEBGL
  • ext.COLOR_ATTACHMENT3_WEBGL
  • ext.COLOR_ATTACHMENT4_WEBGL
  • ext.COLOR_ATTACHMENT5_WEBGL
  • ext.COLOR_ATTACHMENT6_WEBGL
  • ext.COLOR_ATTACHMENT7_WEBGL
  • ext.COLOR_ATTACHMENT8_WEBGL
  • ext.COLOR_ATTACHMENT9_WEBGL
  • ext.COLOR_ATTACHMENT10_WEBGL
  • ext.COLOR_ATTACHMENT11_WEBGL
  • ext.COLOR_ATTACHMENT12_WEBGL
  • ext.COLOR_ATTACHMENT13_WEBGL
  • ext.COLOR_ATTACHMENT14_WEBGL
  • ext.COLOR_ATTACHMENT15_WEBGL

Return value

None.

Examples

See WEBGL_draw_buffers for more context with this example code.

ext.drawBuffersWEBGL([
  ext.COLOR_ATTACHMENT0_WEBGL, // gl_FragData[0]
  ext.COLOR_ATTACHMENT1_WEBGL, // gl_FragData[1]
  ext.COLOR_ATTACHMENT2_WEBGL, // gl_FragData[2]
  ext.COLOR_ATTACHMENT3_WEBGL  // gl_FragData[3]
]);

Specifications

Specification Status Comment
WEBGL_draw_buffersThe definition of 'WEBGL_draw_buffers' in that specification. Recommendation Initial definition.
OpenGL ES 3.0The definition of 'glDrawBuffers' in that specification. Standard Man page of the (similar) OpenGL API.

Browser compatibility

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
drawBuffersWEBGL Chrome

Full support Yes

Edge

Full support 17

Firefox No support ? — 28

Prefixed' Disabled'

No support ? — 28

Prefixed' Disabled'

Prefixed' Implemented with the vendor prefix: MOZ_ Disabled' Until version 28 (exclusive): this feature is behind the webgl.enable-draft-extensions preference (needs to be set to true). To change preferences in Firefox, visit about:config. Full support 28


IE

?

Opera

Full support Yes

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

?

Opera Android

Full support Yes

Safari iOS

?

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
User must explicitly enable this feature.'
User must explicitly enable this feature.
Requires a vendor prefix or different name for use.'
Requires a vendor prefix or different name for use.


See also