Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt3D C++Read FBO



  • how to read FBO by c++ in qt3d?



  • ok make it. i found a way
    Qt3DExtras::Qt3DWindow m_window;
    auto m_3drender = new Qt3DExtras::QForwardRenderer;
    auto capture = new Qt3DRender::QRenderCapture;
    m_3drender->setParent(capture);
    m_window.setActiveFrameGraph(capture);
    auto m_shadercapture = new MyShaderCapture(capture, NULL);



  • class MyShaderCapture : public QObject
    {
    Q_OBJECT
    public:
    MyShaderCapture(Qt3DRender::QRenderCapture* capture, QLabel imageLabel)
    : m_capture(capture)
    , m_reply(nullptr)
    , m_imageLabel(imageLabel)
    , m_continuous(false)
    {
    }
    public slots:
    void onCompleted()
    {
    QObject::disconnect(connection);
    emit sg2handleshaderreply( m_reply->image() );
    //m_imageLabel->setPixmap();
    //m_reply->saveImage("capture.bmp");
    delete m_reply;
    m_reply = nullptr;
    if (m_continuous)
    capture();
    }
    void setContinuous(bool continuos)
    {
    m_continuous = continuos;
    }
    void capture()
    {
    if (!m_reply) {
    m_reply = m_capture->requestCapture();
    connection = QObject::connect(m_reply, &Qt3DRender::QRenderCaptureReply::completed,
    this, &MyShaderCapture::onCompleted);
    }
    }
    signals:
    void sg2handleshaderreply(QImage&img);
    private:
    Qt3DRender::QRenderCapture
    m_capture;
    Qt3DRender::QRenderCaptureReply *m_reply;
    QMetaObject::Connection connection;
    QLabel *m_imageLabel;
    bool m_continuous;
    };
    hope help others for this func



  • who could told me how to read the fragment shader mutilply outputs?Many thanks


Log in to reply