1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 14:38:34 +01:00

made graphics extensions not cause an exception

This commit is contained in:
Ellpeck 2020-01-26 01:18:53 +01:00
parent 00b07e1c45
commit 0a1147df9d

View file

@ -9,18 +9,17 @@ 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;
}