大网数据广告活动
Web 标准与前端开发

WEBGL_draw_buffers: drawBuffersWEBGL() method

· 52CE 我爱测

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.

WebGL

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 WebGL2RenderingContext, this method is available as WebGL2RenderingContext.drawBuffers() by default and the constants are named gl.COLOR_ATTACHMENT1 etc. without the "WEBGL" suffix.

Syntax

drawBuffersWEBGL(buffers)

Parameters

  • buffers
    • : An Array of WebGL_API/Types 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_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 (undefined).

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

Browser compatibility

See also

  • WEBGL_draw_buffers
  • WebGLRenderingContext.getExtension()
  • WebGLRenderingContext.framebufferRenderbuffer()
  • WebGLRenderingContext.framebufferTexture2D()
  • WebGLRenderingContext.getFramebufferAttachmentParameter()
  • WebGLRenderingContext.getParameter()
  • WebGL deferred shading - Mozilla Hacks blog

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。