Exemplo n.º 1
0
        // =====================================================================
        //
        // XNA SPECIFIC FUNCTIONS
        //
        // =====================================================================

        /// <summary>
        /// Initialize
        /// ----------
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Window.Title = CMain.GameTitle;
            gGraphicsDeviceManager.PreferMultiSampling = true;
            gGraphicsDeviceManager.IsFullScreen        = CConfig.GetConfigBOOL("Fullscreen");

            if (gGraphicsDeviceManager.IsFullScreen == true)
            {
                int Width;
                int Height;

                try
                {
                    Width  = Convert.ToInt32(CConfig.GetConfigSTRING("Width"));
                    Height = Convert.ToInt32(CConfig.GetConfigSTRING("Height"));
                }
                catch
                {
                    Width  = 1024;
                    Height = 768;
                }

                gGraphicsDeviceManager.PreferredBackBufferWidth  = Width;
                gGraphicsDeviceManager.PreferredBackBufferHeight = Height;
            }
            else
            {
                gGraphicsDeviceManager.PreferredBackBufferWidth  = 1024;
                gGraphicsDeviceManager.PreferredBackBufferHeight = 768;
            }

            if (CConfig.GetConfigBOOL("Vertical Sync") == true)
            {
                gGraphicsDeviceManager.SynchronizeWithVerticalRetrace = true;
                gGraphicsDeviceManager.GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Default;
            }
            else
            {
                gGraphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
                gGraphicsDeviceManager.GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Immediate;

                TargetElapsedTime = TimeSpan.FromMilliseconds(1);
            }
            IsFixedTimeStep = true;

            gGraphicsDeviceManager.ApplyChanges();
            gGraphicsDevice = gGraphicsDeviceManager.GraphicsDevice;

            gCMain   = new CMain();
            gCCommon = new CCommon();
            gCGamma  = new CGamma();

            base.Initialize();
        }
Exemplo n.º 2
0
        // =====================================================================
        //
        // XNA SPECIFIC FUNCTIONS
        //
        // =====================================================================
        /// <summary>
        /// Initialize
        /// ----------
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Window.Title = CMain.GameTitle;
            gGraphicsDeviceManager.PreferMultiSampling = true;
            gGraphicsDeviceManager.IsFullScreen = CConfig.GetConfigBOOL("Fullscreen");

            if (gGraphicsDeviceManager.IsFullScreen == true)
            {
                int Width;
                int Height;

                try
                {
                    Width = Convert.ToInt32(CConfig.GetConfigSTRING("Width"));
                    Height = Convert.ToInt32(CConfig.GetConfigSTRING("Height"));
                }
                catch
                {
                    Width = 1024;
                    Height = 768;
                }

                gGraphicsDeviceManager.PreferredBackBufferWidth = Width;
                gGraphicsDeviceManager.PreferredBackBufferHeight = Height;
            }
            else
            {
                gGraphicsDeviceManager.PreferredBackBufferWidth = 1024;
                gGraphicsDeviceManager.PreferredBackBufferHeight = 768;
            }

            if (CConfig.GetConfigBOOL("Vertical Sync") == true)
            {
                gGraphicsDeviceManager.SynchronizeWithVerticalRetrace = true;
                gGraphicsDeviceManager.GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Default;
            }
            else
            {
                gGraphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
                gGraphicsDeviceManager.GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Immediate;

                TargetElapsedTime = TimeSpan.FromMilliseconds(1);
            }
            IsFixedTimeStep = true;

            gGraphicsDeviceManager.ApplyChanges();
            gGraphicsDevice = gGraphicsDeviceManager.GraphicsDevice;

            gCMain = new CMain();
            gCCommon = new CCommon();
            gCGamma = new CGamma();

            base.Initialize();
        }