mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 17:59:24 +01:00
Revert "made graphics extensions not cause an exception"
This reverts commit 0a1147df
This commit is contained in:
parent
0a1147df9d
commit
58b90d90be
1 changed files with 6 additions and 5 deletions
|
@ -9,17 +9,18 @@ namespace MLEM.Extensions {
|
||||||
private static int lastHeight;
|
private static int lastHeight;
|
||||||
|
|
||||||
public static void SetFullscreen(this GraphicsDeviceManager manager, bool fullscreen) {
|
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;
|
manager.IsFullScreen = fullscreen;
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
|
lastWidth = manager.GraphicsDevice.Viewport.Width;
|
||||||
|
lastHeight = manager.GraphicsDevice.Viewport.Height;
|
||||||
|
|
||||||
var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
|
var curr = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
|
||||||
manager.PreferredBackBufferWidth = curr.Width;
|
manager.PreferredBackBufferWidth = curr.Width;
|
||||||
manager.PreferredBackBufferHeight = curr.Height;
|
manager.PreferredBackBufferHeight = curr.Height;
|
||||||
} else {
|
} 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.PreferredBackBufferWidth = lastWidth;
|
||||||
manager.PreferredBackBufferHeight = lastHeight;
|
manager.PreferredBackBufferHeight = lastHeight;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue