mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-23 05:08:34 +01:00
added ApplyChangesSafely
This commit is contained in:
parent
58b90d90be
commit
0824ba1098
1 changed files with 13 additions and 2 deletions
|
@ -11,8 +11,9 @@ namespace MLEM.Extensions {
|
||||||
public static void SetFullscreen(this GraphicsDeviceManager manager, bool fullscreen) {
|
public static void SetFullscreen(this GraphicsDeviceManager manager, bool fullscreen) {
|
||||||
manager.IsFullScreen = fullscreen;
|
manager.IsFullScreen = fullscreen;
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
lastWidth = manager.GraphicsDevice.Viewport.Width;
|
var view = manager.GraphicsDevice.Viewport;
|
||||||
lastHeight = manager.GraphicsDevice.Viewport.Height;
|
lastWidth = view.Width;
|
||||||
|
lastHeight = view.Height;
|
||||||
|
|
||||||
var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
|
var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
|
||||||
manager.PreferredBackBufferWidth = curr.Width;
|
manager.PreferredBackBufferWidth = curr.Width;
|
||||||
|
@ -27,5 +28,15 @@ namespace MLEM.Extensions {
|
||||||
manager.ApplyChanges();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue