PDA

View Full Version : Whats the difference in sharing a QGLContext and sharing a QGLWidget



Wali
15th October 2009, 17:55
Hi,
In the QGLWidget constructor

QGLWidget::QGLWidget ( QGLContext * context, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )

How is sharing a QGLContext different from sharing a QGLWidget? It seems to me that passing in a context is the same as sharing a widget. The shared widget and the newly constructed QGLWidget will be sharing the same context any way. So, why is there the option to pass in a context?

Thanks

high_flyer
15th October 2009, 18:24
What do you mean when you say "sharing a QGLWidget"?

Wali
15th October 2009, 20:45
When creating a QGLWidget you can pass its constructor a pointer to another QGLWidget to mutually share a context.

QGLWidget::QGLWidget ( QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )

What does it mean to pass in a QGLContext and another QGLWidget, as in the following constructor.

QGLWidget::QGLWidget ( QGLContext * context, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )

high_flyer
16th October 2009, 10:30
Here is what the docs say, maybe you can ask specifically what it is you don't understand in the following (for a shared 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().

And a context is:

An OpenGL rendering context is a complete set of OpenGL state variables.


As you can see, sharing openGL "resources" (as shared QGLWidget) and sharing "rendering state variables" is not the same.

Did I help you?

Wali
17th October 2009, 23:31
Ok I think I understand thanks.