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
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
bb10
Zeno Albisser 2012-10-24 16:04:15 +02:00 committed by The Qt Project
parent 03967c4f0b
commit 9214b39beb
2 changed files with 22 additions and 1 deletions

View File

@ -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<QGLXContext *>(context->handle());
return glxPlatformContext->glxContext();
#else
Q_UNUSED(context);
return 0;
#endif
}
QT_END_NAMESPACE

View File

@ -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;