qt5+osg多线程的解决方案

问题描述:
Cannot make QOpenGLContext current in a different thread
解决思路:
在主线程中将qt窗体中的QOpenglContext moveToThread到窗体线程中,这样窗体线程在执行makecurrent时就不会报错。moveToThread必须在QOpenglContext原来所在的线程中执行,否则会失败,提示以上问题信息。以下工程文件中还解决了单线程模式中出现的QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined告警,这主要是因为osg进入帧循环后,相应的窗体还没有显示出来。
补充说明:
开发环境为win7x64 qt5.4 osg3.3 vs2010
工程文件:https://pan.baidu.com/s/1DZpn9bahTqiuAc88w5HThw

猜你喜欢

转载自blog.csdn.net/hankern/article/details/81734709