[PyQt] Errors while rendering to multiple QGLWidgets in a multi-threaded app
Michael Broxton
broxton at stanford.edu
Fri Oct 28 03:04:40 BST 2011
Hi there,
I'm attempting to write a PyQt application that renders to different QGLWidgets from different threads (there is one QGLWidget accessed in each thread, and each thread only renders to its one widget -- therefore the opengl contexts should be strictly kept to their separate threads). However my application crashes soon after two or more QGLWidgets are open and rendering. It looks very much like the two threads are rendering into the same OpenGL context, with a typical error message looking like this:
GLError(
err = 1282,
description = 'invalid operation',
baseOperation = glEnd,
cArguments = ()
)
as if glEnd() had been called twice in a row in the same context without a glBegin() in between. This shouldn't happen if the threads are rendering into different contexts, though, and I have very carefully checked using Apple's OpenGL Profiling tool and each thread definitely has its own gl context. After a lot of debugging, I'm stumped as to why this is happening! I have created a very simple test program that illustrates the problem here:
https://gist.github.com/1318290
For more background: I'm running OSX 10.7.2 on a macbook pro with Qt version 4.7.4 and PyQt 4.8.6. I have also tested this program on a similarly configured Windows 7 machine, and experienced the same problem.
My test code is based on this old(ish) article about multi-threaded GL rendering in Qt, available here:
http://doc.qt.nokia.com/qq/qq06-glimpsing.html#writingmultithreadedglapplications
A straight C++ implementation (snagged from the github repo of Anders Wallin) of this method can be downloaded here:
http://graphics.stanford.edu/~broxton/qt_opengl_threads.tgz
My python test harness is essentially identical to this C++ code, but the C++ code compiles and runs fine on my computer without any issue. Everything on the 'net leads me to believe that I'm doing this multi-threaded rendering correctly, so I think that this is a Python/OpenGL or PyQt related issue, and not a Qt issue. Thus, it feels like it is time to escalate the issue and seek out some help!
Any assistance in figuring this out would be greatly appreciated. Thanks!
-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20111027/80fed678/attachment.html>
More information about the PyQt
mailing list