From 1789ffaaf07b61cf449134ed6ec014b86c996494 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 27 Jul 2015 09:58:22 -0500 Subject: [PATCH] fix crash when minimizing window in gdi+ display method --- .../IGL_GdiPlus.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/IGL_GdiPlus.cs b/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/IGL_GdiPlus.cs index 6a39adb0f1..acc1c37d8d 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/IGL_GdiPlus.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/IGL_GdiPlus.cs @@ -287,8 +287,18 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus public Matrix4 CreateGuiProjectionMatrix(sd.Size dims) { Matrix4 ret = Matrix4.Identity; - ret.M11 = 2.0f / (float)dims.Width; - ret.M22 = 2.0f / (float)dims.Height; + + //must handle 0s here otherwise we generate infinity and that causes problems later with gdi+ + //gdi+ is additionally sensitive to otherwise reasonable (say, 0,0,0,0 matrices) so use a 1 here i guess + + if (dims.Width == 0) + ret.M11 = 1; + else ret.M11 = 2.0f / (float)dims.Width; + + if (dims.Height == 0) + ret.M22 = 1; + else ret.M22 = 2.0f / (float)dims.Height; + return ret; }