From 8be41e4f2ce353a97a2d41bee78cc99ca12b619a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 11 Feb 2014 11:07:37 +0100 Subject: OPENGL: Add notification function about context destruction. --- backends/graphics/opengl/opengl-graphics.cpp | 20 ++++++++++++++++++++ backends/graphics/opengl/opengl-graphics.h | 8 ++++++++ 2 files changed, 28 insertions(+) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index a97f680f15..3b92acc505 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -881,6 +881,26 @@ void OpenGLGraphicsManager::notifyContextChange(const Graphics::PixelFormat &def #endif } +void OpenGLGraphicsManager::notifyContextDestroy() { + if (_gameScreen) { + _gameScreen->releaseInternalTexture(); + } + + if (_overlay) { + _overlay->releaseInternalTexture(); + } + + if (_cursor) { + _cursor->releaseInternalTexture(); + } + +#ifdef USE_OSD + if (_osd) { + _osd->releaseInternalTexture(); + } +#endif +} + void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) { if (_overlayVisible) { // It might be confusing that we actually have to handle something diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 93c0c5bc83..8d53dbe062 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -136,6 +136,14 @@ protected: */ void notifyContextChange(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha); + /** + * Notify the manager that the OpenGL context is about to be destroyed. + * This will free up/reset internal OpenGL related state and *must* be + * called whenever a context might be created again after destroying a + * context. + */ + void notifyContextDestroy(); + /** * Adjust the physical mouse coordinates according to the currently visible screen. */ -- cgit v1.2.3