smokris
smokris

Reputation: 11850

How to create a QGLWidget from a CGLContextObj?

I'm using Qt 4.8.4 on Mac OS 10.8.

I already have a CGLContextObj (created outside my control).

I would like to create a QGLWidget from (or at least shared with) my existing CGLContextObj — so I can render the textures which were created on the CGLContextObj.

How can I create a QGLContext from the existing CGLContextObj?


Already tried

Upvotes: 2

Views: 444

Answers (1)

jlstrecker
jlstrecker

Reputation: 5033

QPA (Qt Platform Abstraction) was still a work in progress in Qt 4. It's fully integrated into Qt 5. If you have the option to upgrade to Qt 5, things might be easier.

In Qt 5, you can construct a QCocoaGLContext (a derived class of QPlatformOpenGLContext), and from that get a QOpenGLContext (QPlatformOpenGLContext::context()), and from that get a QGLContext (QGLContext::fromOpenGLContext(QOpenGLContext *)). That gets you pretty close, but how do you get from a CGLContextObj to a QCocoaGLContext?

Unfortunately, I don't see an option to construct a QCocoaGLContext from a CGLContextObj. It does have a NSOpenGLContext private data member, which is initialized inside the existing constructor, so maybe you could add another constructor.

Upvotes: 4

Related Questions