From a91c68601f390999a5691b17fc452521ddd691f9 Mon Sep 17 00:00:00 2001 From: aspioupiou Date: Thu, 30 Apr 2020 13:04:22 +0200 Subject: [PATCH] EGLDisplay non-terminating when mixing WindowlessEGLApplication & shared contexts --- .../Platform/WindowlessEglApplication.cpp | 18 ++++++++++++++++-- src/Magnum/Platform/WindowlessEglApplication.h | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index 1d156633f..27c3f6442 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -83,6 +83,8 @@ bool extensionSupported(const char* const extensions, Containers::ArrayView + * and will return the same EGLDisplay handle.` This makes a problem when + * the context is shared with another one, because both shares the same EGLDisplay. + * To avoid errors when trying to make current the other context (EGL_NOT_INITIALIZED) + * we don't terminate the shared display. + * It is then the user's responsaibility to first kill the shared EGL instance + * (which won't terminate the display), and then main one, killing everything. + */ + if(_sharedContext && _display) eglTerminate(_display); } WindowlessEglContext& WindowlessEglContext::operator=(WindowlessEglContext && other) { diff --git a/src/Magnum/Platform/WindowlessEglApplication.h b/src/Magnum/Platform/WindowlessEglApplication.h index bc023f85b..f7566d452 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.h +++ b/src/Magnum/Platform/WindowlessEglApplication.h @@ -132,6 +132,9 @@ class WindowlessEglContext { EGLContext glContext() { return _context; } private: + /* Stores whether the EGL context is shared or not */ + bool _sharedContext = false; + EGLDisplay _display{}; EGLContext _context{}; #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)