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:
@@ -59,7 +59,10 @@ enum EventType
|
|||||||
etJoyButtonDown, // 27
|
etJoyButtonDown, // 27
|
||||||
etJoyButtonUp, // 28
|
etJoyButtonUp, // 28
|
||||||
|
|
||||||
etSysWM, //29
|
etSysWM, // 29
|
||||||
|
|
||||||
|
etRenderContextLost, // 30
|
||||||
|
etRenderContextRestored, // 31
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EventFlags
|
enum EventFlags
|
||||||
|
|||||||
@@ -361,6 +361,12 @@ public:
|
|||||||
// display lists. So Work around it.
|
// display lists. So Work around it.
|
||||||
gTextureContextVersion++;
|
gTextureContextVersion++;
|
||||||
|
|
||||||
|
if (mIsOpenGL)
|
||||||
|
{
|
||||||
|
Event contextLost(etRenderContextLost);
|
||||||
|
ProcessEvent(contextLost);
|
||||||
|
}
|
||||||
|
|
||||||
mSDLSurface = SDL_SetVideoMode(inWidth, inHeight, 32, mFlags);
|
mSDLSurface = SDL_SetVideoMode(inWidth, inHeight, 32, mFlags);
|
||||||
|
|
||||||
if (mIsOpenGL)
|
if (mIsOpenGL)
|
||||||
@@ -382,6 +388,9 @@ public:
|
|||||||
mOpenGLContext->IncRef();
|
mOpenGLContext->IncRef();
|
||||||
mPrimarySurface->DecRef();
|
mPrimarySurface->DecRef();
|
||||||
mPrimarySurface = new HardwareSurface(mOpenGLContext);
|
mPrimarySurface = new HardwareSurface(mOpenGLContext);
|
||||||
|
|
||||||
|
Event contextRestored(etRenderContextRestored);
|
||||||
|
ProcessEvent(contextRestored);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -414,6 +423,12 @@ public:
|
|||||||
// display lists. So Work around it.
|
// display lists. So Work around it.
|
||||||
gTextureContextVersion++;
|
gTextureContextVersion++;
|
||||||
|
|
||||||
|
if (mIsOpenGL)
|
||||||
|
{
|
||||||
|
Event contextLost(etRenderContextLost);
|
||||||
|
ProcessEvent(contextLost);
|
||||||
|
}
|
||||||
|
|
||||||
int w = mIsFullscreen ? sgDesktopWidth : mWidth;
|
int w = mIsFullscreen ? sgDesktopWidth : mWidth;
|
||||||
int h = mIsFullscreen ? sgDesktopHeight : mHeight;
|
int h = mIsFullscreen ? sgDesktopHeight : mHeight;
|
||||||
if (mIsFullscreen)
|
if (mIsFullscreen)
|
||||||
@@ -441,6 +456,9 @@ public:
|
|||||||
mOpenGLContext->IncRef();
|
mOpenGLContext->IncRef();
|
||||||
mPrimarySurface->DecRef();
|
mPrimarySurface->DecRef();
|
||||||
mPrimarySurface = new HardwareSurface(mOpenGLContext);
|
mPrimarySurface = new HardwareSurface(mOpenGLContext);
|
||||||
|
|
||||||
|
Event contextRestored(etRenderContextRestored);
|
||||||
|
ProcessEvent(contextRestored);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -113,7 +113,11 @@ public:
|
|||||||
void Resize(int inWidth,int inHeight)
|
void Resize(int inWidth,int inHeight)
|
||||||
{
|
{
|
||||||
ResetHardwareContext();
|
ResetHardwareContext();
|
||||||
|
Event contextLost(etRenderContextLost);
|
||||||
|
HandleEvent(contextLost);
|
||||||
mHardwareContext->SetWindowSize(inWidth,inHeight);
|
mHardwareContext->SetWindowSize(inWidth,inHeight);
|
||||||
|
Event contextRestored(etRenderContextRestored);
|
||||||
|
HandleEvent(contextRestored);
|
||||||
Event evt(etResize, inWidth, inHeight);
|
Event evt(etResize, inWidth, inHeight);
|
||||||
HandleEvent(evt);
|
HandleEvent(evt);
|
||||||
}
|
}
|
||||||
@@ -314,7 +318,7 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ResetHardwareContext();
|
//ResetHardwareContext();
|
||||||
sStage->Resize(inWidth,inHeight);
|
sStage->Resize(inWidth,inHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user