Fix minimize crash

This commit is contained in:
Magnus Norddahl 2016-09-04 03:15:50 +02:00
parent dc39a006dc
commit 5f02e08c8e
2 changed files with 9 additions and 0 deletions

View file

@ -444,6 +444,8 @@ void FGLRenderer::ClearBorders()
int clientWidth = framebuffer->GetClientWidth();
int clientHeight = framebuffer->GetClientHeight();
if (clientWidth == 0 || clientHeight == 0)
return;
glViewport(0, 0, clientWidth, clientHeight);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

View file

@ -231,6 +231,13 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds)
// Back buffer letterbox for the final output
int clientWidth = framebuffer->GetClientWidth();
int clientHeight = framebuffer->GetClientHeight();
if (clientWidth == 0 || clientHeight == 0)
{
// When window is minimized there may not be any client area.
// Pretend to the rest of the render code that we just have a very small window.
clientWidth = 160;
clientHeight = 120;
}
int screenWidth = framebuffer->GetWidth();
int screenHeight = framebuffer->GetHeight();
float scale = MIN(clientWidth / (float)screenWidth, clientHeight / (float)screenHeight);