protected override void Initialize() { if (isSoftwareEmbedded) { // Create the graphics device IGraphicsDeviceManager graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (graphicsDeviceManager != null) { graphicsDeviceManager.CreateDevice(); } else { throw new Exception("Unable to retrieve GraphicsDeviceManager"); } // Width must a multiple of 2 em_renderTarget2D = new RenderTarget2D(GraphicsDevice, em_sizeViewport.X, em_sizeViewport.Y, true, SurfaceFormat.Bgr565, DepthFormat.Depth16); } Game.CGameManagement.currentState = "CInGame"; Game.CGameManagement.Initialize(); SamplerState sState = new SamplerState(); sState.Filter = TextureFilter.Linear; graphics.GraphicsDevice.SamplerStates[0] = sState; Display2D.C2DEffect.softwareViewport = GraphicsDevice.Viewport; base.Initialize(); }
protected virtual void Initialize() { this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; this.graphicsDeviceService = this.Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; switch (Window.Context.Resources.Configuration.Orientation) { case Android.Content.Res.Orientation.Portrait: Window.SetOrientation(DisplayOrientation.Portrait); break; case Android.Content.Res.Orientation.Landscape: Window.SetOrientation(DisplayOrientation.LandscapeLeft); break; default: Window.SetOrientation(DisplayOrientation.LandscapeLeft); break; } foreach (GameComponent gc in _gameComponentCollection) { gc.Initialize(); } if ((this.graphicsDeviceService != null) && (this.graphicsDeviceService.GraphicsDevice != null)) { LoadContent(); } }
public GraphicsHandler(IGameProxy gameProxy, IGraphicsDeviceManager graphicsDeviceManager) { _game = gameProxy; _game.LoadContentEvent += LoadContent; _game.DrawEvent += Draw; ((GraphicsDeviceManager)graphicsDeviceManager).PreparingDeviceSettings += PreparingDeviceSettings; }
private void DoInitialize() { AssertNotDisposed(); if (GraphicsDevice == null) { IGraphicsDeviceManager graphicsDeviceManager = Services.GetService( typeof(IGraphicsDeviceManager) ) as IGraphicsDeviceManager; graphicsDeviceManager.CreateDevice(); } Initialize(); /* We need to do this after virtual Initialize(...) is called. * 1. Categorize components into IUpdateable and IDrawable lists. * 2. Subscribe to Added/Removed events to keep the categorized * lists synced and to Initialize future components as they are * added. */ CategorizeComponents(); _components.ComponentAdded += Components_ComponentAdded; _components.ComponentRemoved += Components_ComponentRemoved; }
public void Run() { if (inRun) { throw new InvalidOperationException("Run Method called more than once"); } inRun = true; BeginRun(); gameHost.Initialize(); graphicsManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager)); if (graphicsManager != null) { graphicsManager.CreateDevice(); } graphicsService = (IGraphicsDeviceService)Services.GetService(typeof(IGraphicsDeviceService)); if (graphicsService != null) { /*graphicsService.DeviceCreated += DeviceCreated; * graphicsService.DeviceResetting += DeviceResetting; * graphicsService.DeviceReset += DeviceReset; * graphicsService.DeviceDisposing += DeviceDisposing;*/ } Initialize(); isActive = true; gameHost.Run(); EndRun(); inRun = false; }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } } #if ANDROID Activity = null; #endif _isDisposed = true; _instance = null; } }
public EndlessGame(IClientWindowSizeProvider windowSizeProvider, IGraphicsDeviceRepository graphicsDeviceRepository, IControlSetRepository controlSetRepository, IControlSetFactory controlSetFactory, ITestModeLauncher testModeLauncher, IPubFileLoadActions pubFileLoadActions, ILoggerProvider loggerProvider, IChatBubbleTextureProvider chatBubbleTextureProvider) { _graphicsDeviceRepository = graphicsDeviceRepository; _controlSetRepository = controlSetRepository; _controlSetFactory = controlSetFactory; _testModeLauncher = testModeLauncher; _pubFileLoadActions = pubFileLoadActions; _loggerProvider = loggerProvider; _chatBubbleTextureProvider = chatBubbleTextureProvider; _graphicsDeviceManager = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = windowSizeProvider.Width, PreferredBackBufferHeight = windowSizeProvider.Height }; Content.RootDirectory = "Content"; }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components for (int i = 0; i < _components.Count; i++) { var disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (Content != null) { Content.Dispose(); } if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } Platform.Dispose(); } _isDisposed = true; } }
private void DoInitialize() { AssertNotDisposed(); /* If this is late, you can still create it yourself. * In fact, you can even go as far as creating the * _manager_ before base.Initialize(), but Begin/EndDraw * will not get called. Just... please, make the service * before calling Run(). */ graphicsDeviceManager = (IGraphicsDeviceManager) Services.GetService(typeof(IGraphicsDeviceManager)); if (graphicsDeviceManager != null) { graphicsDeviceManager.CreateDevice(); } Initialize(); /* We need to do this after virtual Initialize(...) is called. * 1. Categorize components into IUpdateable and IDrawable lists. * 2. Subscribe to Added/Removed events to keep the categorized * lists synced and to Initialize future components as they are * added. */ updateableComponents.Clear(); drawableComponents.Clear(); for (int i = 0; i < Components.Count; i += 1) { CategorizeComponent(Components[i]); } Components.ComponentAdded += OnComponentAdded; Components.ComponentRemoved += OnComponentRemoved; }
protected virtual void Dispose(bool disposing) { if (this._isDisposed) { return; } if (disposing) { for (int index = 0; index < this._components.Count; ++index) { IDisposable disposable = this._components[index] as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (this.Content != null) { this.Content.Dispose(); } if (this._graphicsDeviceManager != null) { (this._graphicsDeviceManager as GraphicsDeviceManager).Dispose(); this._graphicsDeviceManager = (IGraphicsDeviceManager)null; } this.Platform.Dispose(); } this._isDisposed = true; }
public void Run() { this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (this.graphicsDeviceManager != null) { this.graphicsDeviceManager.CreateDevice(); } this.Initialize(); this.inRun = true; try { this.BeginRun(); this.gameTime.ElapsedGameTime = TimeSpan.Zero; this.gameTime.ElapsedRealTime = TimeSpan.Zero; this.gameTime.TotalGameTime = this.totalGameTime; this.gameTime.TotalRealTime = this.clock.CurrentTime; this.gameTime.IsRunningSlowly = false; this.Update(this.gameTime); this.doneFirstUpdate = true; if (this.host != null) { this.host.Run(); } this.EndRun(); } finally { this.inRun = false; } }
public void Initialize(IGraphicsDeviceManager graphics) { _appService.CreateAppDirectoryStructure(); _dataService.Initialize(); _graphicsService.Initialize((GraphicsDeviceManager)graphics); _uiService.Initialize((GraphicsDeviceManager)graphics); _screenService.ChangeScreen <MainMenuScreen>(); }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components for (int i = 0; i < _components.Count; i++) { var disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (Content != null) { Content.Dispose(); Content = null; } if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); #if WINDOWS_STOREAPP Platform.ViewStateChanged -= Platform_ApplicationViewChanged; #endif Platform.Dispose(); Platform = null; } Effect.FlushCache(); ContentTypeReaderManager.ClearTypeCreators(); SoundEffect.PlatformShutdown(); BlendState.ResetStates(); DepthStencilState.ResetStates(); RasterizerState.ResetStates(); SamplerState.ResetStates(); } #if ANDROID Activity = null; #endif _isDisposed = true; _instance = null; } }
public void Initialize(IGraphicsDeviceManager graphics) { _objectMapper.Initialize(); _appService.CreateAppDirectoryStructure(); _dataService.Initialize(); _networkService.StartServer(_settingsService.Port); _screenService.ChangeScreen<ServerScreen>(); _systemLoader.LoadSystems(); }
protected virtual void Initialize() { this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; this.graphicsDeviceService = this.Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; if ((this.graphicsDeviceService != null) && (this.graphicsDeviceService.GraphicsDevice != null)) { LoadContent(); } }
/// <summary> /// Call this method to initialize the game, begin running the game loop, and start processing events for the game. /// </summary> /// <param name="gameContext">The window Context for this game.</param> /// <exception cref="System.InvalidOperationException">Cannot run this instance while it is already running</exception> public void Run(GameContext gameContext = null) { if (IsRunning) { throw new InvalidOperationException("Cannot run this instance while it is already running"); } // Gets the graphics device manager graphicsDeviceManager = Services.GetService <IGraphicsDeviceManager>(); if (graphicsDeviceManager == null) { throw new InvalidOperationException("No GraphicsDeviceManager found"); } #if XENKO_PLATFORM_WINDOWS_DESKTOP && XENKO_GRAPHICS_API_VULKAN try { // fix scaling on Windows 8.1+ SetProcessDpiAwareness(2); } catch (Exception e) { } // don't break if we are on windows 8 or lower #endif #if XENKO_GRAPHICS_API_VULKAN // get the resolution now, so we can create our window with the right settings right from the start GraphicsDeviceManager gdm = graphicsDeviceManager as GraphicsDeviceManager; GetDefaultSettings(out gdm.preferredBackBufferWidth, out gdm.preferredBackBufferHeight, out bool fullScreen, out float fov, (gameContext as GameContextSDL)?.Control ?? null); gdm.IsFullScreen = fullScreen; // Gets the GameWindow Context Context = gameContext ?? GameContextFactory.NewDefaultGameContext(gdm.preferredBackBufferWidth, gdm.preferredBackBufferHeight, fullScreen); PrepareContext(fov); #else Context = gameContext ?? GameContextFactory.NewDefaultGameContext(); PrepareContext(); #endif try { // TODO temporary workaround as the engine doesn't support yet resize var graphicsDeviceManagerImpl = (GraphicsDeviceManager)graphicsDeviceManager; Context.RequestedWidth = graphicsDeviceManagerImpl.PreferredBackBufferWidth; Context.RequestedHeight = graphicsDeviceManagerImpl.PreferredBackBufferHeight; Context.RequestedBackBufferFormat = graphicsDeviceManagerImpl.PreferredBackBufferFormat; Context.RequestedDepthStencilFormat = graphicsDeviceManagerImpl.PreferredDepthStencilFormat; Context.RequestedGraphicsProfile = graphicsDeviceManagerImpl.PreferredGraphicsProfile; Context.DeviceCreationFlags = graphicsDeviceManagerImpl.DeviceCreationFlags; gamePlatform.Run(Context); EndRun(); } finally { IsRunning = false; } }
/// <summary> /// Gives derived classes an opportunity to do work before any /// components are initialized. Note that the base implementation sets /// IsActive to true, so derived classes should either call the base /// implementation or set IsActive to true by their own means. /// </summary> public virtual void BeforeInitialize() { IsActive = true; if (this.Game.GraphicsDevice == null) { IGraphicsDeviceManager graphicsDeviceManager = Game.Services.GetService( typeof(IGraphicsDeviceManager) ) as IGraphicsDeviceManager; graphicsDeviceManager.CreateDevice(); } }
protected virtual void Initialize() { this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; this.graphicsDeviceService = this.Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; if ((this.graphicsDeviceService != null) && (this.graphicsDeviceService.GraphicsDevice != null)) { LoadContent(); } // GG EDIT InitializeGameComponents started being called here InitializeGameComponents(); }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components for (int i = 0; i < _components.Count; i++) { var disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (_content != null) { _content.Dispose(); _content = null; } if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } ContentTypeReaderManager.ClearTypeCreators(); if (SoundEffect._systemState == SoundEffect.SoundSystemState.Initialized) { SoundEffect.PlatformShutdown(); } } #if ANDROID Activity = null; #endif _isDisposed = true; _instance = null; } }
public void Initialize(IGraphicsDeviceManager graphics) { _uiEngine = new MonoGameEngine( _graphicsService.GraphicsDevice, _graphicsService.GraphicsDevice.Viewport.Width, _graphicsService.GraphicsDevice.Viewport.Height); SpriteFont font = _contentManager.Load <SpriteFont>("Spritefonts/Segoe_UI_10_Regular"); FontManager.DefaultFont = _uiEngine.Renderer.CreateFont(font); _game.Window.ClientSizeChanged += WindowOnClientSizeChanged; }
/// <summary> /// Call this method to initialize the game, begin running the game loop, and start processing events for the game. /// </summary> /// <param name="gameContext">The window Context for this game.</param> /// <exception cref="System.InvalidOperationException">Cannot run this instance while it is already running</exception> public void Run(GameContext gameContext = null) { if (IsRunning) { throw new InvalidOperationException("Cannot run this instance while it is already running"); } // Gets the graphics device manager graphicsDeviceManager = Services.GetService <IGraphicsDeviceManager>(); if (graphicsDeviceManager == null) { throw new InvalidOperationException("No GraphicsDeviceManager found"); } // Gets the GameWindow Context Context = gameContext ?? GameContextFactory.NewDefaultGameContext(); PrepareContext(); try { // TODO temporary workaround as the engine doesn't support yet resize var graphicsDeviceManagerImpl = (GraphicsDeviceManager)graphicsDeviceManager; Context.RequestedWidth = graphicsDeviceManagerImpl.PreferredBackBufferWidth; Context.RequestedHeight = graphicsDeviceManagerImpl.PreferredBackBufferHeight; Context.RequestedBackBufferFormat = graphicsDeviceManagerImpl.PreferredBackBufferFormat; Context.RequestedDepthStencilFormat = graphicsDeviceManagerImpl.PreferredDepthStencilFormat; Context.RequestedGraphicsProfile = graphicsDeviceManagerImpl.PreferredGraphicsProfile; Context.DeviceCreationFlags = graphicsDeviceManagerImpl.DeviceCreationFlags; gamePlatform.Run(Context); if (gamePlatform.IsBlockingRun) { // If the previous call was blocking, then we can call Endrun EndRun(); } else { // EndRun will be executed on Game.Exit isEndRunRequired = true; } } finally { if (!isEndRunRequired) { IsRunning = false; } } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components. for (int i = 0; i < _components.Count; i += 1) { IDisposable disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (_content != null) { _content.Dispose(); _content = null; } if (_graphicsDeviceManager != null) { // FIXME: Does XNA4 require the GDM to be disposable? -flibit (_graphicsDeviceManager as IDisposable).Dispose(); _graphicsDeviceManager = null; } AudioDevice.Dispose(); if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } ContentTypeReaderManager.ClearTypeCreators(); } AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; _isDisposed = true; Instance = null; } }
protected virtual void Initialize() { this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; this.graphicsDeviceService = this.Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; foreach (GameComponent gc in _gameComponentCollection) { gc.Initialize(); } if ((this.graphicsDeviceService != null) && (this.graphicsDeviceService.GraphicsDevice != null)) { LoadContent(); } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { // Dispose loaded game components for (int i = 0; i < _components.Count; i += 1) { IDisposable disposable = _components[i] as IDisposable; if (disposable != null) { disposable.Dispose(); } } _components = null; if (Content != null) { Content.Dispose(); Content = null; } if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } Effect.FlushCache(); ContentTypeReaderManager.ClearTypeCreators(); } _isDisposed = true; _instance = null; } }
/// <summary> /// Call this method to initialize the game, begin running the game loop, and start processing events for the game. /// </summary> /// <param name="gameContext">The window Context for this game.</param> /// <exception cref="System.InvalidOperationException">Cannot run this instance while it is already running</exception> public void Run(GameContext gameContext = null) { if (IsRunning) { throw new InvalidOperationException("Cannot run this instance while it is already running"); } // Gets the graphics device manager graphicsDeviceManager = Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (graphicsDeviceManager == null) { throw new InvalidOperationException("No GraphicsDeviceManager found"); } if (graphicsDeviceManager == null) { throw new InvalidOperationException("No GraphicsDeviceManager found"); } // Gets the GameWindow Context gameContext = gameContext ?? new GameContext(); try { gamePlatform.Run(gameContext); if (gamePlatform.IsBlockingRun) { // If the previous call was blocking, then we can call Endrun EndRun(); } else { // EndRun will be executed on Game.Exit isEndRunRequired = true; } } finally { if (!isEndRunRequired) { IsRunning = false; } } }
public AnimationHandler(IGameProxy gameProxy, IGraphicsDeviceManager graphicsDeviceManager) { _game = gameProxy; _game.DrawEvent += Draw; _game.UpdateEvent += Update; _game.LoadContentEvent += LoadContent; _barbarianTexture = new AnimatedTexture (new AssetValues { ContentName = "Barbarian/Walking", FrameCount = 4, Depth = 0.5f, Rotation = 0.0f, Scale = 1.0f, Origin = _shipPos, TimePerFrame = 6.0f }); }
public void Run() { // Upper part of Run() method this.m_objGraphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (this.m_objGraphicsDeviceManager != null && this.Canvas != null && this.Canvas.Window != null) { this.m_objGraphicsDeviceManager.CreateDevice(); } if (this.Canvas != null && this.Canvas.Window != null) { this.Initialize(); this.m_bInRun = true; try { this.BeginRun(); this.m_objGameTime = new GameTime(this.m_tsTotalGameTime, this.m_objClock.CurrentTime, false ); this.Update(this.m_objGameTime); this.m_bDoneFirstUpdate = true; if (this.Canvas != null && this.Canvas.Window != null) { //this.Canvas.Window.Owner = Application.Current.MainWindow; this.Canvas.Window.PreRun(); } this.IsRunning = true; } catch { throw; } finally { this.m_bInRun = false; Microsoft.Xna.Framework.Input.Mouse.WindowHandle = this.Canvas.Window.Handle; } } }
protected override void Initialize() { if (isSoftwareEmbedded) { // Create the graphics device IGraphicsDeviceManager graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (graphicsDeviceManager != null) { graphicsDeviceManager.CreateDevice(); } else { throw new Exception("Unable to retrieve GraphicsDeviceManager"); } // Width must a multiple of 2 em_renderTarget2D = new RenderTarget2D(GraphicsDevice, em_sizeViewport.X, em_sizeViewport.Y, true, SurfaceFormat.Bgr565, DepthFormat.Depth16); } camera = new CCamera(GraphicsDevice, Vector3.Up + new Vector3(50f), Vector3.Zero, 0.5f, 10000f); base.Initialize(); }
private GraphicsDevice InitializeGraphicsService() { graphicsDeviceService = (IGraphicsDeviceService) Services.GetService(typeof(IGraphicsDeviceService)); if (graphicsDeviceService == null) { throw new InvalidOperationException( "No Graphics Device Service" ); } graphicsDeviceManager = (IGraphicsDeviceManager) Services.GetService(typeof(IGraphicsDeviceManager)); if (graphicsDeviceManager != null) { graphicsDeviceManager.CreateDevice(); } // This should have been filled by CreateDevice! return(graphicsDeviceService.GraphicsDevice); }
public void Run() { if(inRun) throw new InvalidOperationException("Run Method called more than once"); inRun = true; BeginRun(); gameHost.Initialize(); graphicsManager = (IGraphicsDeviceManager)Services.GetService(typeof (IGraphicsDeviceManager)); if (graphicsManager != null) graphicsManager.CreateDevice(); graphicsService = (IGraphicsDeviceService)Services.GetService(typeof (IGraphicsDeviceService)); if (graphicsService != null) { /*graphicsService.DeviceCreated += DeviceCreated; graphicsService.DeviceResetting += DeviceResetting; graphicsService.DeviceReset += DeviceReset; graphicsService.DeviceDisposing += DeviceDisposing;*/ } Initialize(); isActive = true; gameHost.Run(); EndRun(); inRun = false; }
public void GraphicsDeviceManagerAddsToGameServicesCollectionAsIGraphicsDeviceManagerTest() { IGraphicsDeviceManager s1 = (IGraphicsDeviceManager)game.Services.GetService(typeof(IGraphicsDeviceManager)); Assert.IsNotNull(s1); }
internal override void Initialize(GameContext gameContext) { drawingSurface = (DrawingSurface)gameContext.Control; graphicsDeviceService = (IGraphicsDeviceService)Services.GetService(typeof(IGraphicsDeviceService)); graphicsDeviceManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager)); }
public void Run() { // Upper part of Run() method this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (this.graphicsDeviceManager != null) { this.graphicsDeviceManager.CreateDevice(); } this.Initialize(); this._inRun = true; try { this.BeginRun(); this.gameTime = new GameTime( TimeSpan.Zero, TimeSpan.Zero, this.totalGameTime, this.clock.CurrentTime, false ); this.Update(this.gameTime); this.doneFirstUpdate = true; if (this.Window != null) { this.Window.Owner = Application.Current.MainWindow; this.Window.PreRun(); } this.IsRunning = true; } catch { throw; } finally { this._inRun = false; Microsoft.Xna.Framework.Input.Mouse.WindowHandle = this.Window.Handle; } }
public void Initialize(IGraphicsDeviceManager graphics) { _screenService.ChangeScreen <AreaEditorScreen>(); }
protected virtual void Initialize() { this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; this.graphicsDeviceService = this.Services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; switch (Window.Context.Resources.Configuration.Orientation) { case Android.Content.Res.Orientation.Portrait : Window.SetOrientation(DisplayOrientation.Portrait); break; case Android.Content.Res.Orientation.Landscape : Window.SetOrientation(DisplayOrientation.LandscapeLeft); break; default: Window.SetOrientation(DisplayOrientation.LandscapeLeft); break; } foreach (GameComponent gc in _gameComponentCollection) { gc.Initialize(); } if ((this.graphicsDeviceService != null) && (this.graphicsDeviceService.GraphicsDevice != null)) { LoadContent(); } }
/// <summary> /// Call this method to initialize the game, begin running the game loop, and start processing events for the game. /// </summary> /// <param name="gameContext">The window Context for this game.</param> /// <exception cref="System.InvalidOperationException">Cannot run this instance while it is already running</exception> public void Run(GameContext gameContext = null) { if (IsRunning) { throw new InvalidOperationException("Cannot run this instance while it is already running"); } // Gets the graphics device manager graphicsDeviceManager = Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager; if (graphicsDeviceManager == null) { throw new InvalidOperationException("No GraphicsDeviceManager found"); } // Gets the GameWindow Context Context = gameContext ?? new GameContext(); PrepareContext(); try { // TODO temporary workaround as the engine doesn't support yet resize var graphicsDeviceManagerImpl = (GraphicsDeviceManager) graphicsDeviceManager; Context.RequestedWidth = graphicsDeviceManagerImpl.PreferredBackBufferWidth; Context.RequestedHeight = graphicsDeviceManagerImpl.PreferredBackBufferHeight; Context.RequestedBackBufferFormat = graphicsDeviceManagerImpl.PreferredBackBufferFormat; Context.RequestedDepthStencilFormat = graphicsDeviceManagerImpl.PreferredDepthStencilFormat; Context.RequestedGraphicsProfile = graphicsDeviceManagerImpl.PreferredGraphicsProfile; gamePlatform.Run(Context); if (gamePlatform.IsBlockingRun) { // If the previous call was blocking, then we can call Endrun EndRun(); } else { // EndRun will be executed on Game.Exit isEndRunRequired = true; } } finally { if (!isEndRunRequired) { IsRunning = false; } } }
internal GraphicsDeviceWrapper(IGraphicsDeviceManager graphicsDeviceManager) { _graphicsDeviceManager = graphicsDeviceManager; }