From 5f02e08c8e133f93d9e9e72e004e662d15ef8b7d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 03:15:50 +0200 Subject: [PATCH] Fix minimize crash --- src/gl/renderer/gl_postprocess.cpp | 2 ++ src/gl/renderer/gl_renderer.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 645bc3fe1..e6ca7faad 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -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); diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 6cd38390f..f9d627d93 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -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);