#include #include #include #include #include namespace flightgear { QOpenGLContext* qtContextFromOSG(osg::GraphicsContext* context) { osgViewer::GraphicsWindowCocoa* win = dynamic_cast(context); if (!win) { return nullptr; } auto cnc = QCocoaNativeContext{win->getContext()}; QVariant nativeHandle = QVariant::fromValue(cnc); if (nativeHandle.isNull()) return nullptr; std::unique_ptr qtOpenGLContext(new QOpenGLContext); qtOpenGLContext->setNativeHandle(nativeHandle); if (!qtOpenGLContext->create()) { return nullptr; } return qtOpenGLContext.release(); } QWindow* qtWindowFromOSG(osgViewer::GraphicsWindow* graphicsWindow) { osgViewer::GraphicsWindowCocoa* win = dynamic_cast(graphicsWindow); if (!win) { return nullptr; } NSView* osgView = [win->getContext() view]; return QWindow::fromWinId(reinterpret_cast(osgView)); } } // of namespace flightgear