Browse Source

Platform: add context release also to iOS, WGL and Windows EGL apps.

pull/498/head
Vladimír Vondruš 5 years ago
parent
commit
0145342196
  1. 15
      src/Magnum/Platform/WindowlessIosApplication.h
  2. 8
      src/Magnum/Platform/WindowlessIosApplication.mm
  3. 8
      src/Magnum/Platform/WindowlessWglApplication.cpp
  4. 15
      src/Magnum/Platform/WindowlessWglApplication.h
  5. 8
      src/Magnum/Platform/WindowlessWindowsEglApplication.cpp
  6. 15
      src/Magnum/Platform/WindowlessWindowsEglApplication.h

15
src/Magnum/Platform/WindowlessIosApplication.h

@ -115,10 +115,23 @@ class WindowlessIosContext {
* @brief Make the context current
*
* Prints error message and returns @cpp false @ce on failure,
* otherwise returns @cpp true @ce.
* otherwise returns @cpp true @ce. If the context is current on
* another thread, you have to @ref release() it there first --- an
* OpenGL context can't be current in multiple threads at the same
* time.
*/
bool makeCurrent();
/**
* @brief Release current context
* @m_since_latest
*
* Releases a context previously made current using @ref makeCurrent().
* Prints error message and returns @cpp false @ce on failure,
* otherwise returns @cpp true @ce.
*/
bool release();
/**
* @brief Underlying OpenGL context
* @m_since_latest

8
src/Magnum/Platform/WindowlessIosApplication.mm

@ -74,6 +74,14 @@ bool WindowlessIosContext::makeCurrent() {
return false;
}
bool WindowlessIosContext::release() {
if([EAGLContext setCurrentContext:nil])
return true;
Error() << "Platform::WindowlessIosContext::release(): cannot release current context";
return false;
}
#ifndef DOXYGEN_GENERATING_OUTPUT
WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments): WindowlessIosApplication{arguments, Configuration{}} {}
#endif

8
src/Magnum/Platform/WindowlessWglApplication.cpp

@ -243,6 +243,14 @@ bool WindowlessWglContext::makeCurrent() {
return false;
}
bool WindowlessWglContext::release() {
if(wglMakeCurrent(_deviceContext, nullptr))
return true;
Error() << "Platform::WindowlessWglContext::release(): cannot release current context:" << GetLastError();
return false;
}
WindowlessWglContext::Configuration::Configuration():
#ifndef MAGNUM_TARGET_GLES
_flags{Flag::ForwardCompatible}

15
src/Magnum/Platform/WindowlessWglApplication.h

@ -130,10 +130,23 @@ class WindowlessWglContext {
* @brief Make the context current
*
* Prints error message and returns @cpp false @ce on failure,
* otherwise returns @cpp true @ce.
* otherwise returns @cpp true @ce. If the context is current on
* another thread, you have to @ref release() it there first --- an
* OpenGL context can't be current in multiple threads at the same
* time.
*/
bool makeCurrent();
/**
* @brief Release current context
* @m_since_latest
*
* Releases a context previously made current using @ref makeCurrent().
* 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}

8
src/Magnum/Platform/WindowlessWindowsEglApplication.cpp

@ -173,6 +173,14 @@ bool WindowlessWindowsEglContext::makeCurrent() {
return false;
}
bool WindowlessWindowsEglContext::release() {
if(eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT))
return true;
Error() << "Platform::WindowlessWindowsEglApplication::release(): cannot release current context:" << GetLastError();
return false;
}
#ifndef DOXYGEN_GENERATING_OUTPUT
WindowlessWindowsEglApplication::WindowlessWindowsEglApplication(const Arguments& arguments): WindowlessWindowsEglApplication{arguments, Configuration{}} {}
#endif

15
src/Magnum/Platform/WindowlessWindowsEglApplication.h

@ -115,10 +115,23 @@ class WindowlessWindowsEglContext {
* @brief Make the context current
*
* Prints error message and returns @cpp false @ce on failure,
* otherwise returns @cpp true @ce.
* otherwise returns @cpp true @ce. If the context is current on
* another thread, you have to @ref release() it there first --- an
* OpenGL context can't be current in multiple threads at the same
* time.
*/
bool makeCurrent();
/**
* @brief Release current context
* @m_since_latest
*
* Releases a context previously made current using @ref makeCurrent().
* 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}

Loading…
Cancel
Save