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

@@ -361,6 +361,12 @@ public:
// display lists. So Work around it.
gTextureContextVersion++;
if (mIsOpenGL)
{
Event contextLost(etRenderContextLost);
ProcessEvent(contextLost);
}
mSDLSurface = SDL_SetVideoMode(inWidth, inHeight, 32, mFlags);
if (mIsOpenGL)
@@ -382,6 +388,9 @@ public:
mOpenGLContext->IncRef();
mPrimarySurface->DecRef();
mPrimarySurface = new HardwareSurface(mOpenGLContext);
Event contextRestored(etRenderContextRestored);
ProcessEvent(contextRestored);
}
else
{
@@ -414,6 +423,12 @@ public:
// display lists. So Work around it.
gTextureContextVersion++;
if (mIsOpenGL)
{
Event contextLost(etRenderContextLost);
ProcessEvent(contextLost);
}
int w = mIsFullscreen ? sgDesktopWidth : mWidth;
int h = mIsFullscreen ? sgDesktopHeight : mHeight;
if (mIsFullscreen)
@@ -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);
}
}