The color texture of the custom FBO cannot be configured into Qt normally

31 Views Asked by At

I use Qt's QOpenGLWidget to display a large number of points and blur the OpenGL window.

Below is part of my code:

if (m_activeGLFilter)
{
    GLuint screenTex = 0;

    GLuint depthTex = m_fbo->getDepthTexture();

    GLuint colorTex = m_fbo->getColorTexture();

    GLFilter::ViewportParameters parameters;
    {
        parameters.perspectiveMode = !m_isOrtho;
        parameters.zFar = m_far;
        parameters.zNear = m_near;
        parameters.zoom = 1.0;// m_viewportParams.perspectiveView ? computePerspectiveZoom() : m_viewportParams.zoom; //TODO: doesn't work well with EDL in perspective mode!
    }

    //apply shader
    m_activeGLFilter->shade(depthTex, colorTex, parameters);

    //m_fbo->stop();
    bindFBO(nullptr);
    
    /*screenTex = m_activeGLFilter->getTexture();

    if (glIsTexture(screenTex))
    {
        drawQuad(screenTex);
    }*/
    
    glBindFramebuffer(GL_READ_FRAMEBUFFER, m_activeGLFilter->getFboID()); 
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, defaultFramebufferObject());

    glBlitFramebuffer(0, 0, m_glWidth, m_glHeight, 0, 0, m_glWidth, m_glHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}

if (m_fbo)
{
    bindFBO(nullptr);       
}
else
{
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

My display function works fine and so does the blur function. But after I gave the color texture of the FBO to the Qt default FBO, when drawing the GUI, Qt could not get the color texture, and what it got was black. As seen in RenderDoc, textureSampler is black!

The following is the interface when I use RenderDoc to debug:

After blurring:

After blurring

Drawing GUI:

Drawing GUI

0

There are 0 best solutions below