这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

WebGL2RenderingContext.drawBuffers() 方法在 WebGL 2 API defines draw buffers to which fragment colors are written into. The draw buffer settings are part of the state of the currently bound framebuffer or the drawingbuffer if no framebuffer is bound.

句法

void gl.drawBuffers(buffers);
					

参数

buffers
数组 of GLenum specifying the buffers into which fragment colors will be written. Possible values are:
  • gl.NONE : Fragment shader output is not written into any color buffer.
  • gl.BACK : Fragment shader output is written into the back color buffer.
  • gl.COLOR_ATTACHMENT{0-15} : Fragment shader output is written in the nth color attachment of the current framebuffer.

返回值

None.

异常

  • buffers contains not one of the accepted values, a gl.INVALID_ENUM error is thrown.

范例

gl.drawBuffers([gl.NONE, gl.COLOR_ATTACHMENT1]);
					

规范

规范 状态 注释
WebGL 2.0
The definition of 'drawBuffers' in that specification.
编者草案 Initial definition for WebGL.
OpenGL ES 3.0
The definition of 'glDrawBuffers' in that specification.
标准 Man page of the (similar) OpenGL API.

浏览器兼容性

No compatibility data found. Please contribute data for "api/WebGL2RenderingContext" (depth: WebGL2RenderingContext.drawBuffers) to the MDN 兼容性数据存储库 .

另请参阅

元数据

  • 最后修改:
  1. WebGL API
  2. WebGL2RenderingContext
  3. 方法
    1. beginQuery()
    2. beginTransformFeedback()
    3. bindBufferBase()
    4. bindBufferRange()
    5. bindSampler()
    6. bindTransformFeedback()
    7. bindVertexArray()
    8. blitFramebuffer()
    9. clearBuffer[fiuv]()
    10. clientWaitSync()
    11. compressedTexSubImage3D()
    12. copyBufferSubData()
    13. copyTexSubImage3D()
    14. createQuery()
    15. createSampler()
    16. createTransformFeedback()
    17. createVertexArray()
    18. deleteQuery()
    19. deleteSampler()
    20. deleteSync()
    21. deleteTransformFeedback()
    22. deleteVertexArray()
    23. drawArraysInstanced()
    24. drawBuffers()
    25. drawElementsInstanced()
    26. drawRangeElements()
    27. endQuery()
    28. endTransformFeedback()
    29. fenceSync()
    30. framebufferTextureLayer()
    31. getActiveUniformBlockName()
    32. getActiveUniformBlockParameter()
    33. getActiveUniforms()
    34. getBufferSubData()
    35. getFragDataLocation()
    36. getIndexedParameter()
    37. getInternalformatParameter()
    38. getQuery()
    39. getQueryParameter()
    40. getSamplerParameter()
    41. getSyncParameter()
    42. getTransformFeedbackVarying()
    43. getUniformBlockIndex()
    44. getUniformIndices()
    45. invalidateFramebuffer()
    46. invalidateSubFramebuffer()
    47. isQuery()
    48. isSampler()
    49. isSync()
    50. isTransformFeedback()
    51. isVertexArray()
    52. pauseTransformFeedback()
    53. readBuffer()
    54. renderbufferStorageMultisample()
    55. resumeTransformFeedback()
    56. samplerParameter[if]()
    57. texImage3D()
    58. texStorage2D()
    59. texStorage3D()
    60. texSubImage3D()
    61. transformFeedbackVaryings()
    62. uniform[1234][uif][v]()
    63. uniformBlockBinding()
    64. uniformMatrix[234]x[234]fv()
    65. vertexAttribDivisor()
    66. vertexAttribI4[u]i[v]()
    67. vertexAttribIPointer()
    68. waitSync()
  4. 继承:
    1. WebGLRenderingContext
  5. WebGL 相关页面
    1. ANGLE_instanced_arrays
    2. EXT_blend_minmax
    3. EXT_color_buffer_half_float
    4. EXT_disjoint_timer_query
    5. EXT_frag_depth
    6. EXT_sRGB
    7. EXT_shader_texture_lod
    8. EXT_texture_filter_anisotropic
    9. OES_element_index_uint
    10. OES_standard_derivatives
    11. OES_texture_float
    12. OES_texture_float_linear
    13. OES_texture_half_float
    14. OES_texture_half_float_linear
    15. OES_vertex_array_object
    16. WEBGL_color_buffer_float
    17. WEBGL_compressed_texture_atc
    18. WEBGL_compressed_texture_etc1
    19. WEBGL_compressed_texture_pvrtc
    20. WEBGL_compressed_texture_s3tc
    21. WEBGL_compressed_texture_s3tc_srgb
    22. WEBGL_debug_renderer_info
    23. WEBGL_debug_shaders
    24. WEBGL_depth_texture
    25. WEBGL_draw_buffers
    26. WEBGL_lose_context
    27. WebGLActiveInfo
    28. WebGLBuffer
    29. WebGLContextEvent
    30. WebGLFramebuffer
    31. WebGLObject
    32. WebGLProgram
    33. WebGLQuery
    34. WebGLRenderbuffer
    35. WebGLRenderingContext
    36. WebGLSampler
    37. WebGLShader
    38. WebGLShaderPrecisionFormat
    39. WebGLSync
    40. WebGLTexture
    41. WebGLTransformFeedback
    42. WebGLUniformLocation
    43. WebGLVertexArrayObject