internal void InitializeBeforeRun() { try { using (var profile = Profiler.Begin(GameProfilingKeys.GameInitialize)) { // Initialize this instance and all game systems before trying to create the device. Initialize(); // Make sure that the device is already created graphicsDeviceManager.CreateDevice(); // Gets the graphics device service graphicsDeviceService = Services.GetService <IGraphicsDeviceService>(); if (graphicsDeviceService == null) { throw new InvalidOperationException("No GraphicsDeviceService found"); } // Checks the graphics device if (graphicsDeviceService.GraphicsDevice == null) { throw new InvalidOperationException("No GraphicsDevice found"); } // Setup the graphics device if it was not already setup. SetupGraphicsDeviceEvents(); // Bind Graphics Context enabling initialize to use GL API eg. SetData to texture ...etc BeginDraw(); LoadContentInternal(); IsRunning = true; BeginRun(); autoTickTimer.Reset(); UpdateTime.Reset(UpdateTime.Total); // Run the first time an update using (Profiler.Begin(GameProfilingKeys.GameUpdate)) { Update(UpdateTime); } // Unbind Graphics Context without presenting EndDraw(false); } } catch (Exception ex) { Log.Error("Unexpected exception", ex); throw; } }
internal void InitializeBeforeRun() { try { // Initialize this instance and all game systems before trying to create the device. Initialize(); IsRunning = true; IsActive = true; autoTickTimer.Reset(); UpdateTime.Reset(UpdateTime.Total); // Run the first time an update Update(UpdateTime); } catch (Exception ex) { Log.Error("Unexpected exception", ex); throw; } }