Results 1 to 3 of 3

Thread: FBO query

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2010
    Posts
    6

    FBO query

    I have a few questions regarding FBO's, and in-particular the color attachments.

    Am I correct in thinking that when you draw it clears all the active attachments? So you can't draw once to color attachment 0 using gl_FragData[], and then draw again to color attachment 1 using glFragData[]. And then draw both to the screen.


    If that is the case, do you think I'm better off drawing both things at once and using my shader to put one output in color attachment 0 and the next into color attachment 1. Though what I'm drawing there really isn't any easy way of distinguishing the two.

    Or would I be better off just creating a second FBO? My main concern is whether or not there is some big performance hit with binding different FBOs?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675

    Re: FBO query

    Am I correct in thinking that when you draw it clears all the active attachments? So you can't draw once to color attachment 0 using gl_FragData[], and then draw again to color attachment 1 using glFragData[]. And then draw both to the screen.
    It's all about glDrawBuffers. This function provides the mapping between colors output from the fragment shader and colors written to attached buffers.

    If there is no binding between an output color and an attached buffer, then no color will be written. If there is such a binding, then a color will be written.

    It's like a switchboard. glDrawBuffers tells OpenGL which outputs go to which buffers. The fragment shader outputs are all numbered, either implicitly with glFragData[] indices, or explicitly with user-defined fragment shader outputs that are given an index. And the color buffers are numbers. So it's just a matter of saying which numbers map to which other numbers.

    Just because you have an image bound to a buffer does not mean you have to write to it. To do that, a fragment shader output must be mapped to that buffer with glDrawBuffers.

    For what you seem to want to do, use glDrawBuffers to switch between which buffer gets written to. You do your first pass, where fragment shader output 0 goes to color buffer 0, then you do your second pass, where fragment shader output 0 goes to color buffer 1.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2010
    Posts
    6

    Re: FBO query

    I see, thanks a lot for the explanation. Fixed the problem I was having .

Similar Threads

  1. GPU Query
    By loriordan in forum OpenCL
    Replies: 1
    Last Post: 11-20-2009, 01:00 PM
  2. VBO Map-Unmap query
    By DWilson in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 12-22-2008, 02:14 PM
  3. Occlusion query
    By V-man in forum OpenGL: Advanced Coding
    Replies: 18
    Last Post: 09-05-2006, 06:55 AM
  4. occlusion query IDs
    By zed in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-29-2005, 08:54 AM
  5. Occlusion query
    By Jan in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 04-26-2003, 08:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean