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

Render EGLImageKHR into QOpenGLFramebufferObject



  • I have displayed the camera image in QML.But when I rotate the target model, I get a rip.like this:
    image1.jpg image2.jpg
    this is my some code:

    void updateCameraTexture(){
        ......
        EGLImageKHR img = eglCreateImageKHR(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 0, attribs);
        glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_rightTexture);
        lEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, (GLeglImageOES)img);
    }
    
    class Pan3DInFboRenderer : public QQuickFramebufferObject::Renderer
    {
        void render()
        {
            ......
            updateCameraTexture();
            glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_rightTexture);
            glDrawElements(GL_TRIANGLES, m_undistortRight.m_size, GL_UNSIGNED_SHORT,(const void*)((m_undistortRight.m_offset) * sizeof(unsigned short)));
            update();
        }
        QOpenGLFramebufferObject *createFramebufferObject(const QSize &size)
        {
            QOpenGLFramebufferObjectFormat format;
            format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
            format.setSamples(4);
            return new QOpenGLFramebufferObject(size, format);
        }
        ......
    }
    

    But this is normal:

    void updateCameraTexture(){
        ......
        tex = QImage(":/picture/right.jpg").convertToFormat(QImage::Format_RGBA8888);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.width(), tex.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.bits());
    }
    
    class Pan3DInFboRenderer : public QQuickFramebufferObject::Renderer
    {
        void render()
        {
            ......
            updateCameraTexture();
            glBindTexture(GL_TEXTURE_2D, m_rightTexture);
            glDrawElements(GL_TRIANGLES, m_undistortRight.m_size, GL_UNSIGNED_SHORT,(const void*)((m_undistortRight.m_offset) * sizeof(unsigned short)));
            update();
        }
        QOpenGLFramebufferObject *createFramebufferObject(const QSize &size)
        {
            QOpenGLFramebufferObjectFormat format;
            format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
            format.setSamples(4);
            return new QOpenGLFramebufferObject(size, format);
        }
        ......
    }
    


  • On the left is also a QQuickFramebufferObject: : the Renderer,cannot rotate.
    the right is like :
    Appeared torn basic reason lies in the graphics output frame rate is faster than the display (for example GTX1080 run most of the 1080 p of the game on the market can easily break the frame rate, but most players home display refresh rate is 60 hz), monitor the processing speed can't keep up with the graphics card, on display the first frame of video card lost over time, the frame 2, again, leads to the same picture appear at the same time two frame 1, 2, tear is produced
    But it's not,Because tear doesn't appear on the left.


Log in to reply