Add nsOpenGLContextForContext to QCocoaNativeInterface.
This change enables receiving the native NSOpenGLContext that is used by a QOpenGLContext. 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: Iea7c6abb458acc7aa15926052673270d25d1d9d1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
7120cf16d2
commit
92724e533d
@ -60,6 +60,7 @@ public:
|
|||||||
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
|
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
|
||||||
|
|
||||||
static void *cglContextForContext(QOpenGLContext *context);
|
static void *cglContextForContext(QOpenGLContext *context);
|
||||||
|
static void *nsOpenGLContextForContext(QOpenGLContext* context);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onAppFocusWindowChanged(QWindow *window);
|
void onAppFocusWindowChanged(QWindow *window);
|
||||||
|
@ -69,7 +69,8 @@ void *QCocoaNativeInterface::nativeResourceForContext(const QByteArray &resource
|
|||||||
{
|
{
|
||||||
if (!context)
|
if (!context)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (resourceString.toLower() == "nsopenglcontext")
|
||||||
|
return nsOpenGLContextForContext(context);
|
||||||
if (resourceString.toLower() == "cglcontextobj")
|
if (resourceString.toLower() == "cglcontextobj")
|
||||||
return cglContextForContext(context);
|
return cglContextForContext(context);
|
||||||
|
|
||||||
@ -121,13 +122,19 @@ void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *QCocoaNativeInterface::cglContextForContext(QOpenGLContext* context)
|
void *QCocoaNativeInterface::cglContextForContext(QOpenGLContext* context)
|
||||||
|
{
|
||||||
|
NSOpenGLContext *nsOpenGLContext = static_cast<NSOpenGLContext*>(nsOpenGLContextForContext(context));
|
||||||
|
if (nsOpenGLContext)
|
||||||
|
return [nsOpenGLContext CGLContextObj];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
|
||||||
{
|
{
|
||||||
if (context) {
|
if (context) {
|
||||||
QCocoaGLContext *cocoaGLContext = static_cast<QCocoaGLContext *>(context->handle());
|
QCocoaGLContext *cocoaGLContext = static_cast<QCocoaGLContext *>(context->handle());
|
||||||
if (cocoaGLContext) {
|
if (cocoaGLContext) {
|
||||||
NSOpenGLContext *nsOpenGLContext = cocoaGLContext->nsOpenGLContext();
|
return cocoaGLContext->nsOpenGLContext();
|
||||||
if (nsOpenGLContext)
|
|
||||||
return [nsOpenGLContext CGLContextObj];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user