From 9214b39beb01d69d3667328e7e62ef8d779b3957 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 24 Oct 2012 16:04:15 +0200 Subject: Add glxContextForContext function to QXcbNativeInterface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change enables receiving the native GLXContext object that is used by a QOpenGLContext in case of GLX. This clearly is non-public api that is only meant to be used as a last resort for cases where it is really necessary to get hold of a native context object. Change-Id: I7f1f974f18063ed334b8034a0c0192c875c10cec Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 19 +++++++++++++++++++ src/plugins/platforms/xcb/qxcbnativeinterface.h | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 2a36fb7369..fa5f5f43d0 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -53,6 +53,8 @@ #if defined(XCB_USE_EGL) #include "QtPlatformSupport/private/qeglplatformcontext_p.h" +#elif defined (XCB_USE_GLX) +#include "qglxintegration.h" #endif QT_BEGIN_NAMESPACE @@ -68,6 +70,7 @@ public: insert("connection",QXcbNativeInterface::Connection); insert("screen",QXcbNativeInterface::Screen); insert("eglcontext",QXcbNativeInterface::EglContext); + insert("glxcontext",QXcbNativeInterface::GLXContext); } }; @@ -91,6 +94,9 @@ void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceSt case EglContext: result = eglContextForContext(context); break; + case GLXContext: + result = glxContextForContext(context); + break; default: break; } @@ -191,4 +197,17 @@ void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context) #endif } +void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context) +{ + Q_ASSERT(context); +#if defined(XCB_USE_GLX) + QGLXContext *glxPlatformContext = static_cast(context->handle()); + return glxPlatformContext->glxContext(); +#else + Q_UNUSED(context); + return 0; +#endif + +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index 1223fdc39c..c15d00255a 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -58,7 +58,8 @@ public: Connection, Screen, GraphicsDevice, - EglContext + EglContext, + GLXContext }; QXcbNativeInterface(); @@ -76,6 +77,7 @@ public: void *screenForWindow(QWindow *window); void *graphicsDeviceForWindow(QWindow *window); static void *eglContextForContext(QOpenGLContext *context); + static void *glxContextForContext(QOpenGLContext *context); private: const QByteArray m_genericEventFilterType; -- cgit v1.2.3