Add events when the GL rendering context is lost/restored (only affects old SDL backend and Android target right now)

This commit is contained in:
Joshua Granick
2013-12-05 17:09:41 -08:00
parent 29ef53dc6b
commit b07b770db5
3 changed files with 28 additions and 3 deletions

View File

@@ -59,7 +59,10 @@ enum EventType
etJoyButtonDown, // 27
etJoyButtonUp, // 28
etSysWM, //29
etSysWM, // 29
etRenderContextLost, // 30
etRenderContextRestored, // 31
};
enum EventFlags

View File

@@ -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
{

View File

@@ -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);
}
}