public void SetResolution(int width, int height, WindowedFullscreenMode windowedFullscreenMode) { this.windowedFullscreenMode = windowedFullscreenMode; mResolutionWidth = width; mResolutionHeight = height; ResetDevice(); #if !WINDOWS SizeOrOrientationChanged?.Invoke(this, null); #endif }
public void SetResolution(int width, int height, bool isFullscreen) { WindowedFullscreenMode windowedFullscreenMode; if (isFullscreen) { windowedFullscreenMode = WindowedFullscreenMode.Fullscreen; } else { windowedFullscreenMode = WindowedFullscreenMode.Windowed; } SetResolution(width, height, windowedFullscreenMode); }
public GraphicsOptions(Game game, GraphicsDeviceManager graphics) { // We used to call this here, but that makes HandleClientSizeOrOrientationChange get called first, before // internal code, and that means that custom code gets logic before internal, which can result in resolutions being wrong... //if (game != null) //{ // game.Window.ClientSizeChanged += new EventHandler<EventArgs>(HandleClientSizeOrOrientationChange); //} this.game = game; if (graphics != null) { mResolutionWidth = graphics.PreferredBackBufferWidth; mResolutionHeight = graphics.PreferredBackBufferHeight; } mTextureFilter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear; mUseMultiSampling = false; #if MONODROID if (graphics != null) { if (graphics.IsFullScreen) { this.windowedFullscreenMode = WindowedFullscreenMode.Fullscreen; } else { this.windowedFullscreenMode = WindowedFullscreenMode.Windowed; } } #endif #if !MONODROID #region Get Resolution SuspendDeviceReset(); //graphicsOptions.ResolutionWidth = graphics.GraphicsDevice.DisplayMode.Width;// game.Window.ClientBounds.Width; //graphicsOptions.ResolutionHeight = graphics.GraphicsDevice.DisplayMode.Height;//game.Window.ClientBounds.Height; if (game != null) { #if WINDOWS_8 // For some reason the W8 window reports the wrong // width/height if the game is started when in portrait // mode but the user wants to be in landscape. But the GraphicsDevice // is right. Go figure. ResolutionWidth = graphics.GraphicsDevice.Viewport.Width; ResolutionHeight = graphics.GraphicsDevice.Viewport.Height; #elif IOS || UWP || DESKTOP_GL // For UWP and WindowsGL projects the game.Window.ClientBounds is not accurate until after initialize, as explained here: // http://community.monogame.net/t/graphicsdevice-viewport-doesnt-return-the-real-size-of-uwp-game-window/7314/5 ResolutionWidth = graphics.PreferredBackBufferWidth; ResolutionHeight = graphics.PreferredBackBufferHeight; #else ResolutionWidth = game.Window.ClientBounds.Width; ResolutionHeight = game.Window.ClientBounds.Height; #endif } if (graphics != null) { } ResumeDeviceReset(); #endregion #endif // November 15, 2013 // Not sure why this is // here. We do this same // code up above when we check // if the game is not null. This // causes the event to fire twice. //#if WINDOWS_8 // game.Window.OrientationChanged += new EventHandler<EventArgs>(HandleClientSizeOrOrientationChange); // game.Window.ClientSizeChanged += new EventHandler<EventArgs>(HandleClientSizeOrOrientationChange); //#endif }