Skip to content

Instantly share code, notes, and snippets.

@zenoalbisser
Created October 24, 2012 14:17
Show Gist options
  • Select an option

  • Save zenoalbisser/3946313 to your computer and use it in GitHub Desktop.

Select an option

Save zenoalbisser/3946313 to your computer and use it in GitHub Desktop.
commit bbf54a13302bb95e238c7204acbfc376e7d55d8f
Author: Zeno Albisser <zeno@webkit.org>
Date: Wed Oct 24 16:04:15 2012 +0200
Add glxContextForContext function to QXcbNativeInterface.
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
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 335866d..2bd5854 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -55,6 +55,8 @@
#include "QtPlatformSupport/private/qeglplatformcontext_p.h"
#elif defined (XCB_USE_DRI2)
#include "qdri2context.h"
+#elif defined (XCB_USE_GLX)
+#include "qglxintegration.h"
#endif
QT_BEGIN_NAMESPACE
@@ -71,6 +73,7 @@ public:
insert("screen",QXcbNativeInterface::Screen);
insert("graphicsdevice",QXcbNativeInterface::GraphicsDevice);
insert("eglcontext",QXcbNativeInterface::EglContext);
+ insert("glxcontext",QXcbNativeInterface::GLXContext);
}
};
@@ -94,6 +97,9 @@ void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceSt
case EglContext:
result = eglContextForContext(context);
break;
+ case GLXContext:
+ result = glxContextForContext(context);
+ break;
default:
break;
}
@@ -229,4 +235,17 @@ void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context)
#endif
}
+void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+#if defined(XCB_USE_GLX)
+ QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(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 1223fdc..c15d002 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment