2019-12-01 22:58:20 +01:00
|
|
|
using System;
|
2019-11-08 15:35:15 +01:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
|
|
|
namespace MLEM.Extensions {
|
|
|
|
public static class GraphicsExtensions {
|
|
|
|
|
|
|
|
private static int lastWidth;
|
|
|
|
private static int lastHeight;
|
|
|
|
|
|
|
|
public static void SetFullscreen(this GraphicsDeviceManager manager, bool fullscreen) {
|
2020-01-26 01:18:53 +01:00
|
|
|
if (fullscreen || lastWidth == 0 || lastHeight == 0) {
|
|
|
|
var view = manager.GraphicsDevice.Viewport;
|
|
|
|
lastWidth = view.Width;
|
|
|
|
lastHeight = view.Height;
|
|
|
|
}
|
2019-11-08 15:35:15 +01:00
|
|
|
manager.IsFullScreen = fullscreen;
|
|
|
|
if (fullscreen) {
|
|
|
|
var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
|
|
|
|
manager.PreferredBackBufferWidth = curr.Width;
|
|
|
|
manager.PreferredBackBufferHeight = curr.Height;
|
|
|
|
} else {
|
|
|
|
manager.PreferredBackBufferWidth = lastWidth;
|
|
|
|
manager.PreferredBackBufferHeight = lastHeight;
|
|
|
|
}
|
|
|
|
manager.ApplyChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|