// This method calls the game Initialize and BeginRun methods before it begins the game loop and starts // processing events for the game. public void Run() { _lastUpdate = DateTime.Now; // In an original XNA game the GraphicsDevice property is null during initialization // but before the Game's Initialize method is called the property is available so we can // only assume that it should be created somewhere in here. We can not set the viewport // values correctly based on the Preferred settings which is causing some problems on some // Microsoft samples which we are not handling correctly. graphicsDeviceManager.CreateDevice(); var manager = Services.GetService(typeof(IGraphicsDeviceManager)) as GraphicsDeviceManager; Microsoft.Xna.Framework.Graphics.Viewport _vp = new Microsoft.Xna.Framework.Graphics.Viewport(); _vp.X = 0; _vp.Y = 0; _vp.Width = manager.PreferredBackBufferWidth; _vp.Height = manager.PreferredBackBufferHeight; GraphicsDevice.Viewport = _vp; _initializing = true; // Moving the GraphicsDevice creation to here also modifies when GameComponents are being // initialized. // Use OpenGL context locking in delegate function // InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate (InitializeGameComponents); // // // Invoke on thread from the pool // initD.BeginInvoke ( // delegate (IAsyncResult iar) // { // // We must have finished initialising, so set our flag appropriately // // So that we enter the Update loop // _initialized = true; // _initializing = false; // }, // initD); InitializeGameComponents(); _initialized = true; _initializing = false; Initialize(); _view.Run(FramesPerSecond / (FramesPerSecond * TargetElapsedTime.TotalSeconds)); _mainWindow.MakeKeyAndOrderFront(_mainWindow); }
public void Run() { _lastUpdate = DateTime.Now; // In an original XNA game the GraphicsDevice property is null during initialization // but before the Game's Initialize method is called the property is available so we can // only assume that it should be created somewhere in here. We can not set the viewport // values correctly based on the Preferred settings which is causing some problems on some // Microsoft samples which we are not handling correctly. graphicsDeviceManager.CreateDevice(); var manager = Services.GetService(typeof(IGraphicsDeviceManager)) as GraphicsDeviceManager; Microsoft.Xna.Framework.Graphics.Viewport _vp = new Microsoft.Xna.Framework.Graphics.Viewport(); _vp.X = 0; _vp.Y = 0; _vp.Width = manager.PreferredBackBufferWidth; _vp.Height = manager.PreferredBackBufferHeight; GraphicsDevice.Viewport = _vp; _view.Run(FramesPerSecond / (FramesPerSecond * TargetElapsedTime.TotalSeconds)); _view.MainContext = _view.EAGLContext; _view.ShareGroup = _view.MainContext.ShareGroup; _view.BackgroundContext = new MonoTouch.OpenGLES.EAGLContext(_view.ContextRenderingApi, _view.ShareGroup); Accelerometer.SetupAccelerometer(); Initialize(); // Draw the splash screen to the render buffer before making the window visible so // there is no flicker when a blank render buffer is made visible DrawSplashScreen(); _view.SwapBuffers(); //Show the window _mainWindow.MakeKeyAndVisible(); // Listen out for rotation changes ObserveDeviceRotation(); }
public void Run() { _lastUpdate = DateTime.Now; _view.Run(FramesPerSecond / (FramesPerSecond * TargetElapsedTime.TotalSeconds)); _view.MainContext = _view.EAGLContext; _view.ShareGroup = _view.MainContext.ShareGroup; _view.BackgroundContext = new MonoTouch.OpenGLES.EAGLContext(_view.ContextRenderingApi, _view.ShareGroup); //Show the window _mainWindow.MakeKeyAndVisible(); // Get the Accelerometer going Accelerometer.SetupAccelerometer(); Initialize(); // Listen out for rotation changes ObserveDeviceRotation(); }
public void Run() { _lastUpdate = DateTime.Now; // In an original XNA game the GraphicsDevice property is null during initialization // but before the Game's Initialize method is called the property is available so we can // only assume that it should be created somewhere in here. We can not set the viewport // values correctly based on the Preferred settings which is causing some problems on some // Microsoft samples which we are not handling correctly. graphicsDeviceManager.CreateDevice(); var manager = Services.GetService(typeof(IGraphicsDeviceManager)) as GraphicsDeviceManager; // here /*if(this._isFixedTimeStep) * { * _view.Run(FramesPerSecond / ( FramesPerSecond * TargetElapsedTime.TotalSeconds ) ); * } * else*/ { _view.Run(); } _view.MainContext = _view.EAGLContext; _view.ShareGroup = _view.MainContext.ShareGroup; _view.BackgroundContext = new OpenGLES.EAGLContext(_view.ContextRenderingApi, _view.ShareGroup); //Show the window _mainWindow.MakeKeyAndVisible(); Accelerometer.SetupAccelerometer(); Initialize(); // Listen out for rotation changes ObserveDeviceRotation(); }