diff --git a/project/include/Display.h b/project/include/Display.h index aefcaf270..d2b39ff2d 100644 --- a/project/include/Display.h +++ b/project/include/Display.h @@ -59,7 +59,10 @@ enum EventType etJoyButtonDown, // 27 etJoyButtonUp, // 28 - etSysWM, //29 + etSysWM, // 29 + + etRenderContextLost, // 30 + etRenderContextRestored, // 31 }; enum EventFlags diff --git a/project/src/backend/sdl/SDLStage.cpp b/project/src/backend/sdl/SDLStage.cpp index add5bd687..aa1b18e15 100644 --- a/project/src/backend/sdl/SDLStage.cpp +++ b/project/src/backend/sdl/SDLStage.cpp @@ -360,6 +360,12 @@ public: // Calling this recreates the gl context and we loose all our textures and // display lists. So Work around it. gTextureContextVersion++; + + if (mIsOpenGL) + { + Event contextLost(etRenderContextLost); + ProcessEvent(contextLost); + } mSDLSurface = SDL_SetVideoMode(inWidth, inHeight, 32, mFlags); @@ -374,7 +380,7 @@ public: limeEGLResize(window, inWidth, inHeight); } #endif - + //lime_resize_id ++; mOpenGLContext->DecRef(); mOpenGLContext = HardwareContext::CreateOpenGL(0, 0, sgIsOGL2); @@ -382,6 +388,9 @@ public: mOpenGLContext->IncRef(); mPrimarySurface->DecRef(); mPrimarySurface = new HardwareSurface(mOpenGLContext); + + Event contextRestored(etRenderContextRestored); + ProcessEvent(contextRestored); } else { @@ -413,6 +422,12 @@ public: // Calling this recreates the gl context and we loose all our textures and // display lists. So Work around it. gTextureContextVersion++; + + if (mIsOpenGL) + { + Event contextLost(etRenderContextLost); + ProcessEvent(contextLost); + } int w = mIsFullscreen ? sgDesktopWidth : mWidth; int h = mIsFullscreen ? sgDesktopHeight : mHeight; @@ -441,6 +456,9 @@ public: mOpenGLContext->IncRef(); mPrimarySurface->DecRef(); mPrimarySurface = new HardwareSurface(mOpenGLContext); + + Event contextRestored(etRenderContextRestored); + ProcessEvent(contextRestored); } else { diff --git a/project/src/platform/android/AndroidFrame.cpp b/project/src/platform/android/AndroidFrame.cpp index 46583ff1e..cab6230c7 100644 --- a/project/src/platform/android/AndroidFrame.cpp +++ b/project/src/platform/android/AndroidFrame.cpp @@ -113,7 +113,11 @@ public: void Resize(int inWidth,int inHeight) { ResetHardwareContext(); + Event contextLost(etRenderContextLost); + HandleEvent(contextLost); mHardwareContext->SetWindowSize(inWidth,inHeight); + Event contextRestored(etRenderContextRestored); + HandleEvent(contextRestored); Event evt(etResize, inWidth, inHeight); HandleEvent(evt); } @@ -314,7 +318,7 @@ public: } else { - ResetHardwareContext(); + //ResetHardwareContext(); sStage->Resize(inWidth,inHeight); } }