QOpenGL draw in to separate QOpenGLFramebufferObject - wrong buffer draw in ?



  • Hey

    I'm trying to do some selection processing for which I would like to draw my current context in to another buffer. However for some reason it still gets drawn in my main QOpenglWidget.

    Here is the code that runs in a function - not paint related function.

    makeCurrent();
            QOpenGLFramebufferObjectFormat fboFormat;
            fboFormat.setSamples(0);
            fboFormat.setAttachment(QOpenGLFramebufferObject::Depth);
            QOpenGLFramebufferObject fbo(size(), fboFormat);
            fbo.bind();
            QOpenGLPaintDevice deviceX(size()); // do I need it here if I just draw geometries and do no paiting?
            QPainter painterX; // do I need it here if I just draw geometries and do no paiting?
            painterX.begin(&deviceX); // do I need it here if I just draw geometries and do no paiting?
            //glEnable(GL_DEPTH_TEST);
            glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
            mScene->drawScene(viewProj, false);
            painterX.end();
            fbo.release();
            auto img = fbo.toImage();
            label->setPixmap(QPixmap::fromImage(imt));
            label->show(); /// used for debug
            QOpenGLFramebufferObject::bindDefault(); /// rebing back old proper widget FBO ?
            doneCurrent();
    
    

    When I run this set of commands, my main window changes but it should... not?

    Any help would be great.

    TIA


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.