Reputation: 11850
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
?
QGLContext::fromPlatformGLContext()
, but this method appears to only be available when Qt is built in QPA mode (...but ./configure -qpa cocoa
fails to build, and I haven't been able to find any documentation on exactly what the -qpa
flag does).Upvotes: 2
Views: 444
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