slayton
slayton

Reputation: 20319

Multiple QGLWidgets with a single openGL Context in C++

I'm writing an application that is composed of multiple (16-32) plots that are updated several times a second and are drawn using openGL. Until now I've down most of the prototyping of the plots with GLUT. However I'd like to adopt a full fledge framework like QT and I'm getting ready to write a test QGLWidget.

Before I get started I'd like to figure out if its possible for multiple QGLWidgets to share a single openGL context? If so is there anything specifics I need to keep track of when sharing an openGL context between widgets?

Upvotes: 3

Views: 5169

Answers (2)

datenwolf
datenwolf

Reputation: 162347

if its possible for multiple QGLWidgets to share a single openGL context?

Now this is not possible to answer in general, because it depends on the platform in question: On X11/GLX it is indeed possible to use an indirect context on multiple drawables, however the context can be active on only one drawable at a time.

However:

It is also possible (and it is the recommended way to do this) to have multiple contexts share their data. In the very first versions of OpenGL this was only display lists, hence this still called list sharing. But with current versions of OpenGL this also includes textures, Pixel Buffer Objects and Vertex Buffer Objects. Frame Buffer Objects however can not be shared, but since textures can be used as FBO attachments that's no big deal.

QGLWidget provides a straigtforward API to share context data between QGLWidgests' contexts.

Upvotes: 3

BЈовић
BЈовић

Reputation: 64283

Yes, it is possible to share an opengl context by using this constructor.

If so is there anything specifics I need to keep track of when sharing an openGL context between widgets?

I am not sure, but I don't think there is anything special you need to take care of.

Upvotes: 1

Related Questions