1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

added ApplyChangesSafely

This commit is contained in:
Ellpeck 2020-01-26 01:31:40 +01:00
parent 58b90d90be
commit 0824ba1098

View file

@ -11,8 +11,9 @@ namespace MLEM.Extensions {
public static void SetFullscreen(this GraphicsDeviceManager manager, bool fullscreen) {
manager.IsFullScreen = fullscreen;
if (fullscreen) {
lastWidth = manager.GraphicsDevice.Viewport.Width;
lastHeight = manager.GraphicsDevice.Viewport.Height;
var view = manager.GraphicsDevice.Viewport;
lastWidth = view.Width;
lastHeight = view.Height;
var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
manager.PreferredBackBufferWidth = curr.Width;
@ -27,5 +28,15 @@ namespace MLEM.Extensions {
manager.ApplyChanges();
}
public static void ApplyChangesSafely(this GraphicsDeviceManager manager) {
// If we don't do this, then applying changes will cause the
// graphics device manager to reset the window size to the
// size set when starting the game :V
var view = manager.GraphicsDevice.Viewport;
manager.PreferredBackBufferWidth = view.Width;
manager.PreferredBackBufferHeight = view.Height;
manager.ApplyChanges();
}
}
}