summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt/qwinrteglcontext.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-10-31 19:08:25 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-02 08:48:51 +0000
commit9b735a46182350e42495053ca741150a06f5c546 (patch)
tree326af7f04aa8dc8521581ab8b0eacfe81febf35c /src/plugins/platforms/winrt/qwinrteglcontext.cpp
parent97b564374b99be4e3c077e6999e61d3d6688cf17 (diff)
WinRT: Add support for QOpenGLWidget
Also involves adding support for sharing contexts. Task-number: QTBUG-48663 Change-Id: I0b18846ae70b63a0a21132f820a12ea744c0e936 Reviewed-by: Andrew Knight <andrew.knight@intopalo.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrteglcontext.cpp')
-rw-r--r--src/plugins/platforms/winrt/qwinrteglcontext.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.cpp b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
index c0ff92f738..3fd0278360 100644
--- a/src/plugins/platforms/winrt/qwinrteglcontext.cpp
+++ b/src/plugins/platforms/winrt/qwinrteglcontext.cpp
@@ -70,9 +70,11 @@ Q_GLOBAL_STATIC(WinRTEGLDisplay, g)
class QWinRTEGLContextPrivate
{
public:
+ QWinRTEGLContextPrivate() : eglContext(EGL_NO_CONTEXT), eglShareContext(EGL_NO_CONTEXT) { }
QSurfaceFormat format;
EGLConfig eglConfig;
EGLContext eglContext;
+ EGLContext eglShareContext;
};
QWinRTEGLContext::QWinRTEGLContext(QOpenGLContext *context)
@@ -81,6 +83,8 @@ QWinRTEGLContext::QWinRTEGLContext(QOpenGLContext *context)
Q_D(QWinRTEGLContext);
d->format = context->format();
d->format.setRenderableType(QSurfaceFormat::OpenGLES);
+ if (QPlatformOpenGLContext *shareHandle = context->shareHandle())
+ d->eglShareContext = static_cast<QWinRTEGLContext *>(shareHandle)->d_ptr->eglContext;
}
QWinRTEGLContext::~QWinRTEGLContext()
@@ -126,7 +130,7 @@ void QWinRTEGLContext::initialize()
EGL_CONTEXT_FLAGS_KHR, flags,
EGL_NONE
};
- d->eglContext = eglCreateContext(g->eglDisplay, d->eglConfig, nullptr, attributes);
+ d->eglContext = eglCreateContext(g->eglDisplay, d->eglConfig, d->eglShareContext, attributes);
if (d->eglContext == EGL_NO_CONTEXT) {
qWarning("QEGLPlatformContext: Failed to create context: %x", eglGetError());
return;
@@ -136,7 +140,7 @@ void QWinRTEGLContext::initialize()
bool QWinRTEGLContext::makeCurrent(QPlatformSurface *windowSurface)
{
Q_D(QWinRTEGLContext);
- Q_ASSERT(windowSurface->surface()->surfaceType() == QSurface::OpenGLSurface);
+ Q_ASSERT(windowSurface->surface()->supportsOpenGL());
QWinRTWindow *window = static_cast<QWinRTWindow *>(windowSurface);
if (window->eglSurface() == EGL_NO_SURFACE)
@@ -166,7 +170,7 @@ void QWinRTEGLContext::doneCurrent()
void QWinRTEGLContext::swapBuffers(QPlatformSurface *windowSurface)
{
- Q_ASSERT(windowSurface->surface()->surfaceType() == QSurface::OpenGLSurface);
+ Q_ASSERT(windowSurface->surface()->supportsOpenGL());
const QWinRTWindow *window = static_cast<QWinRTWindow *>(windowSurface);
eglSwapBuffers(g->eglDisplay, window->eglSurface());