Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. can't read values from QOpenGLFramebuffer 2nd color attachment
Forum Updated to NodeBB v4.3 + New Features

can't read values from QOpenGLFramebuffer 2nd color attachment

Scheduled Pinned Locked Moved Solved General and Desktop
qopenglframebufopenglfbo
2 Posts 1 Posters 492 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    strattonbrazil
    wrote on 3 Nov 2019, 22:05 last edited by
    #1

    I have a QOpenGLFramebufferObject that I've been writing to and reading from using texture() in another part of the application. I've added a second color attachment to include some additional data, but now I'm having trouble retrieving it.

        _drawFbo = new QOpenGLFramebufferObject(PAINT_FBO_WIDTH, PAINT_FBO_WIDTH, QOpenGLFramebufferObject::Depth);
    
        // I've also tried without the format (uses GL_RGBA)
        _drawFbo->addColorAttachment(PAINT_FBO_WIDTH, PAINT_FBO_WIDTH, GL_RGBA32F);
    

    And then in my shader I write to both places when the shader is bound:

    layout(location=0) out vec4 meshWithPaintColor;
    layout(location=1) out vec4 primitiveId;
    
    void main() {
        ...
        meshWithPaintColor = vec4(finalColor, 0);
        primitiveId = vec4(1,1,1,1);
    

    When I try reading from this 2nd attachment using the textures()[1] value bound to a shader sampler the values always seem to be zero.

    Do I need to do anything with the QOpenGLFramebufferObject to allow drawing to the second color attachment?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      strattonbrazil
      wrote on 8 Nov 2019, 06:37 last edited by
      #2

      I did in fact have to call glDrawBuffers myself. I assumed this was handled by the FBO binding, but apparently not.

      QOpenGLExtraFunctions* f = QOpenGLContext::currentContext()->extraFunctions();
      GLenum bufs[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
      f->glDrawBuffers(2, bufs);
      

      This seems strange to me that the FBO abstraction supports color attachments, but requires extra functions to use them.

      1 Reply Last reply
      0

      2/2

      8 Nov 2019, 06:37

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved