Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How does glDrawBuffer interact with glDrawBuffers

  1. #1
    Newbie Newbie
    Join Date
    Sep 2016
    Posts
    2

    How does glDrawBuffer interact with glDrawBuffers

    From what I understand:

    - glDrawBuffer selects a single draw color buffer attachment in an FBO, or up to four color buffers in the default framebuffer (using aliases); in the latter case the fragment shader will write the same fragment to each color buffer
    - glDrawBuffers creates a table of color buffers whose indexes correspond to fragment shader output locations

    Is this state stored independently?

    What happens with fragment shader with more than one output location in the case where glDrawBuffer was called? Does only the 0 location get written into the specified color buffers?

    Edit: Also I have similar confusion for the result of glClear(GL_COLOR_BUFFER_BIT)-- this will clear *all* the color buffers? only those specified by glDrawBuffer and/or glDrawBuffers?
    Last edited by theold; 11-10-2017 at 08:32 PM.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,476
    Quote Originally Posted by theold View Post
    Is this state stored independently?
    No. GL_DRAW_BUFFER is effectively an alias for GL_DRAW_BUFFER0. The manifest constants have different numeric values, but they refer to the same state (i.e. glGetIntegerv() will always return the same value for both).

    Quote Originally Posted by theold View Post
    What happens with fragment shader with more than one output location in the case where glDrawBuffer was called? Does only the 0 location get written into the specified color buffers?
    Yes. The specification says (17.4.1) "DrawBuffer will set the draw buffer for fragment colors other than zero to NONE."

    Quote Originally Posted by theold View Post
    Edit: Also I have similar confusion for the result of glClear(GL_COLOR_BUFFER_BIT)-- this will clear *all* the color buffers? only those specified by glDrawBuffer and/or glDrawBuffers?
    The latter; the specification says (17.4.3) "the buffers currently enabled for color writing". You can use glClearBuffer() or glClearNamedFramebuffer() to clear individual buffers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •