From 58b90d90be495aa89babdb0f336a016b9168d01c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 26 Jan 2020 01:20:20 +0100 Subject: [PATCH] Revert "made graphics extensions not cause an exception" This reverts commit 0a1147df --- MLEM/Extensions/GraphicsExtensions.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MLEM/Extensions/GraphicsExtensions.cs b/MLEM/Extensions/GraphicsExtensions.cs index 4901c11..a84e01a 100644 --- a/MLEM/Extensions/GraphicsExtensions.cs +++ b/MLEM/Extensions/GraphicsExtensions.cs @@ -9,17 +9,18 @@ namespace MLEM.Extensions { private static int lastHeight; public static void SetFullscreen(this GraphicsDeviceManager manager, bool fullscreen) { - if (fullscreen || lastWidth == 0 || lastHeight == 0) { - var view = manager.GraphicsDevice.Viewport; - lastWidth = view.Width; - lastHeight = view.Height; - } manager.IsFullScreen = fullscreen; if (fullscreen) { + lastWidth = manager.GraphicsDevice.Viewport.Width; + lastHeight = manager.GraphicsDevice.Viewport.Height; + var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; manager.PreferredBackBufferWidth = curr.Width; manager.PreferredBackBufferHeight = curr.Height; } else { + if (lastWidth <= 0 || lastHeight <= 0) + throw new InvalidOperationException("Can't call SetFullscreen to change out of fullscreen mode without going into fullscreen mode first"); + manager.PreferredBackBufferWidth = lastWidth; manager.PreferredBackBufferHeight = lastHeight; }