mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-24 17:29:23 +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) {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue