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:
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. -
use Triple Buffering to fix this problem。
-
Hello @zhangzheng ,
I tried to do similar example and having some trouble.I posted a question to : https://forum.qt.io/topic/122310/creating-eglimagekhr-image-from-render-buffer.
Could you please check and lemme know if you have an idea ?
Regards