我想使用模拟器窗口内的 GLWidget,并希望使用帧缓冲区对象将数据发送到主窗口的 glwidget。
我已经使用信号/槽来实现这一点,但我遇到了很多多线程问题和异常问题。
实现该场景的最佳方法是什么? ![附上我想做的场景图片][1]
最佳答案
如果你想共享framebuffer对象,你应该使用GL上下文资源共享而不是Signal/Slot。后者在主内存中运行,而上下文共享发生在 GPU 上。因此不涉及数据拷贝(通过总线传输并返回!)。
在 QGLWidget 文档中解释了两个小部件如何共享上下文:
If shareWidget is a valid QGLWidget, this widget will share OpenGL display lists and texture objects with shareWidget. But if shareWidget and this widget have different formats, sharing might not be possible. You can check whether sharing is in effect by calling isSharing().
http://doc.qt.nokia.com/4.7-snapshot/qglwidget.html#QGLWidget
关于c++ - Qt 中在两个小部件之间发送 OpenGL 图像的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11594027/