This feature is not Baseline because it does not work in some of the most widely-used browsers.
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.
drawBuffersWEBGL(buffers)
buffersAn 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 n-th color attachment of the framebuffer.ext.COLOR_ATTACHMENT1_WEBGLext.COLOR_ATTACHMENT2_WEBGLext.COLOR_ATTACHMENT3_WEBGLext.COLOR_ATTACHMENT4_WEBGLext.COLOR_ATTACHMENT5_WEBGLext.COLOR_ATTACHMENT6_WEBGLext.COLOR_ATTACHMENT7_WEBGLext.COLOR_ATTACHMENT8_WEBGLext.COLOR_ATTACHMENT9_WEBGLext.COLOR_ATTACHMENT10_WEBGLext.COLOR_ATTACHMENT11_WEBGLext.COLOR_ATTACHMENT12_WEBGLext.COLOR_ATTACHMENT13_WEBGLext.COLOR_ATTACHMENT14_WEBGLext.COLOR_ATTACHMENT15_WEBGLNone (undefined).
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] ]);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
drawBuffersWEBGL |
36 | 17 | 28 | 23 | 9 | No | No | No | 15 | No | No | 15 |
WEBGL_draw_buffersWebGLRenderingContext.getExtension()WebGLRenderingContext.framebufferRenderbuffer()WebGLRenderingContext.framebufferTexture2D()WebGLRenderingContext.getFramebufferAttachmentParameter()WebGLRenderingContext.getParameter()
© 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/WEBGL_draw_buffers/drawBuffersWEBGL