diff --git a/src/Magnum/Platform/WindowlessCglApplication.cpp b/src/Magnum/Platform/WindowlessCglApplication.cpp index 7afb30659..c7e5b4819 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.cpp +++ b/src/Magnum/Platform/WindowlessCglApplication.cpp @@ -97,6 +97,14 @@ bool WindowlessCglContext::makeCurrent() { return false; } +bool WindowlessCglContext::release() { + if(CGLSetCurrentContext(0) == kCGLNoError) + return true; + + Error() << "Platform::WindowlessCglContext::release(): cannot release current context"; + return false; +} + #ifndef DOXYGEN_GENERATING_OUTPUT WindowlessCglApplication::WindowlessCglApplication(const Arguments& arguments): WindowlessCglApplication{arguments, Configuration{}} {} #endif diff --git a/src/Magnum/Platform/WindowlessCglApplication.h b/src/Magnum/Platform/WindowlessCglApplication.h index a32902018..a328c1081 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.h +++ b/src/Magnum/Platform/WindowlessCglApplication.h @@ -126,6 +126,14 @@ class WindowlessCglContext { */ bool makeCurrent(); + /** + * @brief Release current context + * + * Prints error message and returns @cpp false @ce on failure, + * otherwise returns @cpp true @ce. + */ + bool release(); + /** * @brief Underlying OpenGL context * @m_since{2020,06} diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index f75dcf4c0..668a5ef3c 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -503,7 +503,15 @@ bool WindowlessEglContext::makeCurrent() { return true; #endif - Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot make context current:" << Implementation::eglErrorString(eglGetError()); + Error() << "Platform::WindowlessEglApplication::makeCurrent(): cannot make context current:" << Implementation::eglErrorString(eglGetError()); + return false; +} + +bool WindowlessEglContext::release() { + if(eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) + return true; + + Error() << "Platform::WindowlessEglApplication::release(): cannot release current context:" << Implementation::eglErrorString(eglGetError()); return false; } diff --git a/src/Magnum/Platform/WindowlessEglApplication.h b/src/Magnum/Platform/WindowlessEglApplication.h index 04091b0ef..7ac1cb0ca 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.h +++ b/src/Magnum/Platform/WindowlessEglApplication.h @@ -127,6 +127,14 @@ class WindowlessEglContext { */ bool makeCurrent(); + /** + * @brief Release current context + * + * Prints error message and returns @cpp false @ce on failure, + * otherwise returns @cpp true @ce. + */ + bool release(); + /** * @brief Underlying OpenGL context * @m_since{2020,06} diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index a885adb84..4a6d1a249 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -255,6 +255,14 @@ bool WindowlessGlxContext::makeCurrent() { return false; } +bool WindowlessGlxContext::release() { + if(glXMakeContextCurrent(_display, 0, 0, nullptr)) + return true; + + Error() << "Platform::WindowlessGlxContext::release(): cannot release current context"; + return false; +} + WindowlessGlxContext::Configuration::Configuration(): #ifndef MAGNUM_TARGET_GLES _flags{Flag::ForwardCompatible} diff --git a/src/Magnum/Platform/WindowlessGlxApplication.h b/src/Magnum/Platform/WindowlessGlxApplication.h index 0eddcddf8..f58685d55 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.h +++ b/src/Magnum/Platform/WindowlessGlxApplication.h @@ -146,6 +146,14 @@ class WindowlessGlxContext { */ bool makeCurrent(); + /** + * @brief Release current context + * + * Prints error message and returns @cpp false @ce on failure, + * otherwise returns @cpp true @ce. + */ + bool release(); + /** * @brief Underlying OpenGL context * @m_since{2020,06}