diff --git a/src/SFML/System/Android/Activity.hpp b/src/SFML/System/Android/Activity.hpp index 038fa7fe..5edc1dbd 100644 --- a/src/SFML/System/Android/Activity.hpp +++ b/src/SFML/System/Android/Activity.hpp @@ -29,6 +29,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -54,6 +55,7 @@ struct ActivityStates ASensorEventQueue* sensorEventQueue; EGLDisplay display; + EglContext* context; void* savedState; size_t savedStateSize; diff --git a/src/SFML/Window/Android/EglContext.cpp b/src/SFML/Window/Android/EglContext.cpp index bf02706f..c35e1e81 100644 --- a/src/SFML/Window/Android/EglContext.cpp +++ b/src/SFML/Window/Android/EglContext.cpp @@ -87,6 +87,8 @@ m_surface (EGL_NO_SURFACE) ActivityStates* states = getActivity(NULL); sf::Lock lock(states->mutex); + states->context = this; + // Get the intialized EGL display m_display = states->display; diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index da61ed63..ca2f9342 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -41,15 +41,13 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -WindowImplAndroid::WindowImplAndroid(WindowHandle handle) : -m_context (NULL) +WindowImplAndroid::WindowImplAndroid(WindowHandle handle) { } //////////////////////////////////////////////////////////// -WindowImplAndroid::WindowImplAndroid(VideoMode mode, const std::string& title, unsigned long style, const ContextSettings& settings) : -m_context (NULL) +WindowImplAndroid::WindowImplAndroid(VideoMode mode, const std::string& title, unsigned long style, const ContextSettings& settings) { } @@ -93,12 +91,12 @@ void WindowImplAndroid::processEvents() } else if (tempEvent.type == Event::GainedFocus) { - m_context->createSurface(states->window); + states->context->createSurface(states->window); states->updated = true; } else if (tempEvent.type == Event::LostFocus) { - m_context->destroySurface(); + states->context->destroySurface(); states->updated = true; } diff --git a/src/SFML/Window/Android/WindowImplAndroid.hpp b/src/SFML/Window/Android/WindowImplAndroid.hpp index 18fb96a3..b28ca632 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.hpp +++ b/src/SFML/Window/Android/WindowImplAndroid.hpp @@ -151,8 +151,6 @@ public : //////////////////////////////////////////////////////////// virtual void setKeyRepeatEnabled(bool enabled); - EglContext* m_context; - protected : //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index f86e5bcc..939dd3f3 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -123,12 +123,6 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con // Recreate the context m_context = priv::GlContext::create(settings, m_impl, mode.bitsPerPixel); - #ifdef SFML_SYSTEM_ANDROID - // On Android, the window needs its attached context to destroy/recreate - // it when the native window is created/destroyed. - static_cast(m_impl)->m_context = (priv::EglContext*)m_context; - #endif - // Perform common initializations initialize(); }