Dynamic GL: Query gl handle and type via the native interface

Change-Id: I7ca5beaeb57ee2e4e9c175f53ac32371d1f6b5ed
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
bb10
Laszlo Agocs 2014-03-03 18:20:51 +01:00 committed by The Qt Project
parent 2bac49265e
commit e9ebb43419
3 changed files with 46 additions and 2 deletions

View File

@ -52,6 +52,7 @@
#include <QtGui/private/qopengl_p.h>
#include <QtGui/private/qwindow_p.h>
#include <QtGui/QScreen>
#include <qpa/qplatformnativeinterface.h>
#include <private/qopenglextensions_p.h>
#include <private/qopenglversionfunctionsfactory_p.h>
@ -969,13 +970,21 @@ void QOpenGLContext::deleteQGLContext()
The library might be GL-only, meaning that windowing system interface
functions (for example EGL) may live in another, separate library.
\note This function requires that the QGuiApplication instance is already created.
\sa openGLModuleType()
\since 5.3
*/
void *QOpenGLContext::openGLModuleHandle()
{
#ifdef QT_OPENGL_DYNAMIC
QGuiApplication *app = qGuiApp;
Q_ASSERT(app);
return app->platformNativeInterface()->nativeResourceForIntegration(QByteArrayLiteral("glhandle"));
#else
return 0;
#endif
}
/*!
@ -1001,11 +1010,16 @@ void *QOpenGLContext::openGLModuleHandle()
appropriate to check QSurfaceFormat::renderableType() or using the
the convenience function isES().
\note This function requires that the QGuiApplication instance is already created.
\since 5.3
*/
QOpenGLContext::OpenGLModuleType QOpenGLContext::openGLModuleType()
{
#if defined(QT_OPENGL_ES_2)
#if defined(QT_OPENGL_DYNAMIC)
Q_ASSERT(qGuiApp);
return QGuiApplicationPrivate::instance()->platformIntegration()->openGLModuleType();
#elif defined(QT_OPENGL_ES_2)
return GLES2;
#elif defined(QT_OPENGL_ES)
return GLES1;

View File

@ -465,7 +465,31 @@ QPlatformSessionManager *QPlatformIntegration::createPlatformSessionManager(cons
*/
void QPlatformIntegration::sync()
{
}
#ifndef QT_NO_OPENGL
/*!
Platform integration function for querying the OpenGL implementation type.
Used only when dynamic OpenGL implementation loading is enabled.
Subclasses should reimplement this function and return a value based on
the OpenGL implementation they have chosen to load.
\note The return value does not indicate or limit the types of
contexts that can be created by a given implementation. For example
a desktop OpenGL implementation may be capable of creating OpenGL
ES-compatible contexts too.
\sa QOpenGLContext::openGLModuleType(), QOpenGLContext::isES()
\since 5.3
*/
QOpenGLContext::OpenGLModuleType QPlatformIntegration::openGLModuleType()
{
qWarning("This plugin does not support dynamic OpenGL loading!");
return QOpenGLContext::DesktopGL;
}
#endif
QT_END_NAMESPACE

View File

@ -54,6 +54,7 @@
#include <QtGui/qwindowdefs.h>
#include <qpa/qplatformscreen.h>
#include <QtGui/qsurfaceformat.h>
#include <QtGui/qopenglcontext.h>
QT_BEGIN_NAMESPACE
@ -169,6 +170,11 @@ public:
#endif
virtual void sync();
#ifndef QT_NO_OPENGL
virtual QOpenGLContext::OpenGLModuleType openGLModuleType();
#endif
protected:
void screenAdded(QPlatformScreen *screen);
};