/// <summary> /// Initializes SGL. /// </summary> /// <param name="configurator">The Configurator.</param> public static void Initialize(IConfigurator configurator) { if (State != EngineState.NotInitialized) { return; } State = EngineState.Initializing; Components = new ComponentManager(); GameInstance = configurator.GameInstance; Components.Add(configurator.RenderTarget); GraphicsDevice = new GraphicsDevice(configurator.RenderTarget) { BackBuffer = configurator.BackBuffer, ClearColor = Color.CornflowerBlue }; configurator.RenderTarget.Window.Size = new Vector2(configurator.BackBuffer.Width, configurator.BackBuffer.Height); var gameLoop = new GameLoop { TargetTime = 1000 / (float)configurator.TargetFrameRate }; Components.Add(gameLoop); GameInstance.Input = new InputManager(); GameInstance.Content = new ContentManager(); GameInstance.SceneManager = new SceneManager(); GraphicsDevice.RefreshRate = configurator.TargetFrameRate; Components.Add(GameInstance.Content); Components.Add(GraphicsDevice); Components.Add(GameInstance); Components.Add(GameInstance.SceneManager); Components.Add(GameInstance.Input); Components.Get <GameLoop>().Subscribe((IDrawable)GameInstance); Components.Get <GameLoop>().Subscribe((IUpdateable)GameInstance); Components.Get <GameLoop>().Subscribe(GameInstance.Input); //prepare game services var gameServices = new GameServiceContainer(); gameServices.Add(new AchievementProvider()); gameServices.Add(new Gamer()); gameServices.Add(new LaunchParameters()); GameInstance.GameServices = gameServices; Components.Add(new ExceptionHandler()); EngineConfiguration engineConfiguration = GameInstance.OnInitialize(GameInstance.GameServices.GetService <LaunchParameters>()); State = EngineState.Initialized; Run(engineConfiguration); }