QML text rendering issue with custom OpenGL item active

梦想的初衷 提交于 2019-12-13 00:23:39

问题


I've been working with the QmlOgre Qt example to make it work with Qt5 final. The original example itself looks fine now and behaves as intended. My code is here: https://github.com/advancingu/QmlOgre

However I found that there is an issue when a QML text item is modified either through changed signals emitted from C++ or from a simple timer in the sample QML scene. For example, I added a 10ms QML timer that simply increments a counter and assigns it to a text item. The corresponding code is here: https://github.com/advancingu/QmlOgre/tree/issue

What happens now is that on each frame, most characters (except one or two) of the text item randomly disappear. Which of them disappear changes with each frame, so there is a lot of flickering. The characters that do show are the correct ones and at the correct location.

My observation has been that this issue only appears on some application executions, so it very much looks like a threading issue (QmlEngine runs one thread dealing with QML object bindings, QML painting has its own thread in which Ogre lives / must live).

Anyone have ideas on why exactly this is happening or how this can be resolved?

  • Ogre version: 1.8.1
  • Qt version: 5.0.1 (5.1-dev from today has same issue)
  • OS/Distro: Ubuntu 12.04 64bit
  • Graphics driver: tried with Mesa 9.0 and FGLRX (both show it)

回答1:


Still not sure what caused the issue but I found a way to fix it by creating a separate OpenGL context in OgreNode to be used by Ogre. Of course this could cause performance to worsen, however this is still better than things not working reliably. Code in my repository is updated with the fix.




回答2:


In my case, I solved calling glPushAttrib(GL_ALL_ATTRIB_BITS) before the rendering and glPopAttrib() after. You should also ensure all drawing happens between beginNativePainting() and endNativePainting() (see http://doc.qt.io/qt-5.8/qpainter.html#beginNativePainting).



来源:https://stackoverflow.com/questions/15826182/qml-text-rendering-issue-with-custom-opengl-item-active

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!