Reputation: 99
I'm developing an editor in Qt that will have multiple GL contexts running simultaneously in multiple top-level windows. Since VAOs can't be shared between contexts, I'm trying to come up with a way to manage them on a per-context basis, which is proving to be fairly complicated.
It would be a lot simpler if I could just simply use the same context between both, but this doesn't seem to be possible with Qt 5.4. QGLWidget was able to explicitly take a QGLContext pointer as a constructor parameter, but there's no corresponding function for QOpenGLWidget. This is what the documentation says about context sharing:
When multiple QOpenGLWidgets are added as children to the same top-level widget, their contexts will share with each other. This does not apply for QOpenGLWidget instances that belong to different windows.
Is there a way around this?
I can't find too much info on the subject unfortunately, since QOpenGLWidget is relatively new - most of what I can find is talking about QGLWidget.
edit: I'm trying some different things and I've had a little bit of success creating a custom GL widget so I can manage the contexts myself, although there's some bad bugs. However it's sounding like it's actually required to have different contexts for different windows in some cases, which would mean I should just stick with QOpenGLWidget and come up with a VAO-management system. It would be cool if someone with more knowledge/experience on the subject could explain how this works though.
Upvotes: 2
Views: 2152
Reputation: 758
From the QOpenGLWidget documentation:
To set up sharing between QOpenGLWidget instances belonging to different windows, set the Qt::AA_ShareOpenGLContexts application attribute before instantiating QApplication. This will trigger sharing between all QOpenGLWidget instances without any further steps.
According to the Application Attribute documentation, this flag was introduced in version 5.4
Upvotes: 2