From 9b735a46182350e42495053ca741150a06f5c546 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 31 Oct 2015 19:08:25 +0100 Subject: WinRT: Add support for QOpenGLWidget Also involves adding support for sharing contexts. Task-number: QTBUG-48663 Change-Id: I0b18846ae70b63a0a21132f820a12ea744c0e936 Reviewed-by: Andrew Knight Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrteglcontext.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/winrt/qwinrteglcontext.cpp') 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(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(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(windowSurface); eglSwapBuffers(g->eglDisplay, window->eglSurface()); -- cgit v1.2.3