From 017293fdd9ff7817874fac312e773f44d5a6a3df Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 9 Jun 2019 17:42:51 +0300 Subject: [PATCH] (fe150b924) Fix crashing when an invalid resolution is defined in the configs. Probably doesn't fix all crashes due to high resolutions. --- Barotrauma/BarotraumaClient/Source/GameMain.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index 06f5a4490..f14747236 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -189,17 +189,21 @@ namespace Barotrauma { GraphicsWidth = Config.GraphicsWidth; GraphicsHeight = Config.GraphicsHeight; - if (Config.WindowMode == WindowMode.BorderlessWindowed) + switch (Config.WindowMode) { - GraphicsWidth = GraphicsDevice.DisplayMode.Width; - GraphicsHeight = GraphicsDevice.DisplayMode.Height; + case WindowMode.BorderlessWindowed: + GraphicsWidth = GraphicsDevice.DisplayMode.Width; + GraphicsHeight = GraphicsDevice.DisplayMode.Height; + break; + case WindowMode.Windowed: + GraphicsWidth = Math.Min(GraphicsDevice.DisplayMode.Width, GraphicsWidth); + GraphicsHeight = Math.Min(GraphicsDevice.DisplayMode.Height, GraphicsHeight); + break; } GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.Reach; GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color; GraphicsDeviceManager.PreferMultiSampling = false; GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled; - GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth; - GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight; SetWindowMode(Config.WindowMode); defaultViewport = GraphicsDevice.Viewport;