From 8605861f696b5747a5600383df8604e0a13535cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brard?= Date: Wed, 8 Apr 2020 17:24:34 +0200 Subject: [PATCH] Added WindowlessEGLApplication shared context support --- .../Platform/WindowlessEglApplication.cpp | 2 +- src/Magnum/Platform/WindowlessEglApplication.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index e83ce1dbd..062849778 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -273,7 +273,7 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G } #endif - if(!(_context = eglCreateContext(_display, config, EGL_NO_CONTEXT, attributes))) { + if(!(_context = eglCreateContext(_display, config, configuration.sharedContext(), attributes))) { Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot create EGL context:" << Implementation::eglErrorString(eglGetError()); return; } diff --git a/src/Magnum/Platform/WindowlessEglApplication.h b/src/Magnum/Platform/WindowlessEglApplication.h index 0cde69813..cdf411afd 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.h +++ b/src/Magnum/Platform/WindowlessEglApplication.h @@ -255,10 +255,28 @@ class WindowlessEglContext::Configuration { _device = id; return *this; } + /** + * @brief Creates an OpenGL shared context with @param ctx instead + * of creating a brand new one. + */ + Configuration& setSharedcontext(EGLContext ctx) { + _sharedContext = ctx; + return *this; + } + + /** + * @brief Returns the configuration shared context. + * If this has not been specified, (meaning the configuration uses a new opengl context), + * then returns nullptr + */ + EGLContext sharedContext() const { + return _sharedContext; + } #endif private: #ifndef MAGNUM_TARGET_WEBGL + EGLContext _sharedContext{EGL_NO_CONTEXT}; Flags _flags; UnsignedInt _device; #endif