Пример #1
0
        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();
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
 public GraphicsHandler(IGameProxy gameProxy, IGraphicsDeviceManager graphicsDeviceManager)
 {
     _game = gameProxy;
     _game.LoadContentEvent += LoadContent;
     _game.DrawEvent += Draw;
     ((GraphicsDeviceManager)graphicsDeviceManager).PreparingDeviceSettings += PreparingDeviceSettings;
 }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        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;
            }
        }
Пример #7
0
        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";
        }
Пример #8
0
        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;
            }
        }
Пример #9
0
        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;
        }
Пример #10
0
 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;
 }
Пример #11
0
 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;
     }
 }
Пример #12
0
 public void Initialize(IGraphicsDeviceManager graphics)
 {
     _appService.CreateAppDirectoryStructure();
     _dataService.Initialize();
     _graphicsService.Initialize((GraphicsDeviceManager)graphics);
     _uiService.Initialize((GraphicsDeviceManager)graphics);
     _screenService.ChangeScreen <MainMenuScreen>();
 }
Пример #13
0
        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;
            }
        }
Пример #14
0
 public void Initialize(IGraphicsDeviceManager graphics)
 {
     _objectMapper.Initialize();
     _appService.CreateAppDirectoryStructure();
     _dataService.Initialize();
     _networkService.StartServer(_settingsService.Port);
     _screenService.ChangeScreen<ServerScreen>();
     _systemLoader.LoadSystems();
 }
Пример #15
0
        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();
            }
        }
Пример #16
0
        /// <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;
            }
        }
Пример #17
0
        /// <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();
            }
        }
Пример #18
0
        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();
        }
Пример #19
0
        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;
            }
        }
Пример #20
0
        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;
        }
Пример #21
0
        /// <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;
                }
            }
        }
Пример #22
0
        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;
            }
        }
Пример #23
0
        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();
            }
        }
Пример #24
0
        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;
            }
        }
Пример #25
0
        /// <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;
                }
            }
        }
Пример #26
0
        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
                });
        }
Пример #27
0
 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;
         }
     }
 }
Пример #28
0
        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();
        }
Пример #29
0
        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);
        }
Пример #30
0
        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;
        }
Пример #31
0
        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();
            }
        }
        public void GraphicsDeviceManagerAddsToGameServicesCollectionAsIGraphicsDeviceManagerTest()
        {
            IGraphicsDeviceManager s1 = (IGraphicsDeviceManager)game.Services.GetService(typeof(IGraphicsDeviceManager));

            Assert.IsNotNull(s1);
        }
Пример #33
0
 internal override void Initialize(GameContext gameContext)
 {
     drawingSurface = (DrawingSurface)gameContext.Control;
     graphicsDeviceService = (IGraphicsDeviceService)Services.GetService(typeof(IGraphicsDeviceService));
     graphicsDeviceManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager));
 }
 internal override void Initialize(GameContext gameContext)
 {
     drawingSurface = (DrawingSurface)gameContext.Control;
     graphicsDeviceService = (IGraphicsDeviceService)Services.GetService(typeof(IGraphicsDeviceService));
     graphicsDeviceManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager));
 }
Пример #35
0
 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;
     }
 }
Пример #36
0
 public void Initialize(IGraphicsDeviceManager graphics)
 {
     _screenService.ChangeScreen <AreaEditorScreen>();
 }
Пример #37
0
        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();
            }
        }
Пример #38
0
        /// <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;
                }
            }
        }
Пример #39
0
        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();
            }
        }
 internal GraphicsDeviceWrapper(IGraphicsDeviceManager graphicsDeviceManager)
 {
     _graphicsDeviceManager = graphicsDeviceManager;
 }