/// <summary> /// Setup the game properties /// </summary> /// <param name="contentManager">the XNA content manager to be used</param> /// <param name="graphicDeviceManager">the XNA graphic manager to be used</param> public GameProperties(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window) { // load game properties System.Xml.XmlDocument config = new System.Xml.XmlDocument(); config.Load(@"Content/config.xml"); // try resolution try { graphicDeviceManager.PreferredBackBufferWidth = Convert.ToInt32(config.GetElementsByTagName("resolutionX")[0].InnerText); graphicDeviceManager.PreferredBackBufferHeight = Convert.ToInt32(config.GetElementsByTagName("resolutionY")[0].InnerText); Screen screen = Screen.PrimaryScreen; window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.Width / 2 - graphicDeviceManager.PreferredBackBufferWidth / 2, screen.Bounds.Height / 2 - graphicDeviceManager.PreferredBackBufferHeight / 2); } catch (Exception) { graphicDeviceManager.PreferredBackBufferWidth = 1280; graphicDeviceManager.PreferredBackBufferHeight = 720; } // try fullscreen try { int fullscreen = Convert.ToInt32(config.GetElementsByTagName("fullscreen")[0].InnerText); if (fullscreen == 1) { Screen screen = Screen.PrimaryScreen; window.IsBorderless = true; window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.X, screen.Bounds.Y); graphicDeviceManager.PreferredBackBufferWidth = screen.Bounds.Width; graphicDeviceManager.PreferredBackBufferHeight = screen.Bounds.Height; this.isFullscreen = true; } else { this.isFullscreen = false; } } catch (Exception) { } graphicDeviceManager.ApplyChanges(); // try language settings try { this.SelectedLanguage = config.GetElementsByTagName("language")[0].InnerText; } catch(Exception){ } this.currentGameState = GameState.LoadMenu; this.input = new InputHandler(); this.contentManager = new Helper.ContentManager(contentManager); this.spriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(graphicDeviceManager.GraphicsDevice); this.graphicDeviceManager = graphicDeviceManager; this.gameWindow = window; System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(@"Content\Shader\main_shader.mgfxo", System.IO.FileMode.Open)); this.baseShader = new Microsoft.Xna.Framework.Graphics.Effect(this.graphicDeviceManager.GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length)); }
public void InitGraphicsDevice( Microsoft.Xna.Framework.GraphicsDeviceManager manager, Microsoft.Xna.Framework.Graphics.GraphicsDevice device) { manager.PreferredBackBufferWidth = _windowWidth; manager.PreferredBackBufferHeight = _windowHeight; manager.IsFullScreen = _fullScreen; manager.PreferMultiSampling = _preferMultiSampling; manager.ApplyChanges(); }