[Interest] Sharing an OGL context with multiple QGLWidget using designer (or anything else)
Paulo Silva
paulo.jnkml at gmail.com
Tue Jun 19 15:48:29 CEST 2012
Hi everyone,
can I share an OGL context between two or more QGLWidgets, when the
interface is made using designer?.
Since I'm not creating the widgets myself, how can I take the context
of one of the widgets and share it with the other widgets?
I tried to use static class members like:
QGLContext* const MyClass::_shared_context(new QGLContext(QGLFormat()));
QGLWidget* MyClass::_shared_widget(0); // initialized to the first
widget created
and tried to pass it to the constructor,
MyClass(QWidget *parent):
QGLWidget(_shared_context, parent, _shared_widget),
{
static bool once(false);
if(not once) {
once = true;
_shared_widget = this;
} else {
assert(_shared_context == context());
// assert(isSharing()); this always fails
}
}
But it does not seem to work as isSharing() returns false for all widgets.
Appart from that updateGL fails for all widgets but the first. The
others are just painted with the background color.
However they do share the same context, as the first assert holds.
Is there a correct way of doing this? Any designer functionality?
Thanks
Paulo
More information about the Interest
mailing list