private void TryInitializeXna()
		{
			RegisterCommonEngineSingletons();
			game = new XnaGame(this);
			window = new XnaWindow(game);
			window.ViewportPixelSize = settings.Resolution;
			RegisterInstance(window);
			RegisterSingleton<WindowsSystemInformation>();
			var device = new XnaDevice(game, window, settings);
			RegisterInstance(device);
			RegisterSingleton<Drawing>();
			RegisterSingleton<BatchRenderer2D>();
			RegisterSingleton<BatchRenderer3D>();
			game.StartXnaGameToInitializeGraphics();
			RegisterInstance(game);
			RegisterInstance(game.Content);
			RegisterSingleton<XnaSoundDevice>();
			RegisterSingleton<XnaScreenshotCapturer>();
			RegisterSingleton<VideoPlayer>();
			RegisterSingleton<XnaMouse>();
			RegisterSingleton<XnaKeyboard>();
			RegisterSingleton<XnaTouch>();
			RegisterSingleton<XnaGamePad>();
			Register<InputCommands>();
			if (IsAlreadyInitialized)
				throw new UnableToRegisterMoreTypesAppAlreadyStarted();
		}
        private void TryInitializeXna()
        {
            RegisterCommonEngineSingletons();
            game   = new XnaGame(this);
            window = new XnaWindow(game);
            window.ViewportPixelSize = settings.Resolution;
            RegisterInstance(window);
            RegisterSingleton <WindowsSystemInformation>();
            var device = new XnaDevice(game, window, settings);

            RegisterInstance(device);
            RegisterSingleton <Drawing>();
            RegisterSingleton <BatchRenderer2D>();
            RegisterSingleton <BatchRenderer3D>();
            game.StartXnaGameToInitializeGraphics();
            RegisterInstance(game);
            RegisterInstance(game.Content);
            RegisterSingleton <XnaSoundDevice>();
            RegisterSingleton <XnaScreenshotCapturer>();
            RegisterSingleton <XnaMouse>();
            RegisterSingleton <XnaKeyboard>();
            RegisterSingleton <XnaTouch>();
            RegisterSingleton <XnaGamePad>();
            Register <InputCommands>();
            if (IsAlreadyInitialized)
            {
                throw new UnableToRegisterMoreTypesAppAlreadyStarted();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Instead of starting the game normally and blocking we will delay the initialization in
 /// XnaGame until the game class has been constructed and the graphics device is available.
 /// </summary>
 public override void Run(Action runCode = null)
 {
     var game = new XnaGame(this, RaiseInitializedEvent);
     RegisterInstance(game);
     Resolve<XnaDevice>();
     game.Run(runCode);
 }