internal XNAGameAppWrapper(XNALogic logic, Application parent, out Microsoft.Xna.Framework.GamerServices.GamerServicesComponent gamerServicesComponent) { this.parent = parent; this.logic = logic; graphics = new GraphicsDeviceManager(this); graphics.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(PreparingDeviceSettings); graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0; graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0; graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; graphics.SynchronizeWithVerticalRetrace = true; gamerServicesComponent = null; if (parent.ApplicationRequiresGamerServices) { gamerServicesComponent = new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent((Game)this); this.Components.Add(gamerServicesComponent); } #if DEBUG #if !XBOX360 Window.Title += " [DEBUG API]"; #endif #endif presentation = RenderTargetUsage.PlatformContents; parent.SetWindowSizeAndFormat(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferFormat, graphics.PreferredDepthStencilFormat); parent.SetupGraphicsDeviceManager(graphics, ref presentation); //values may have changed in SetupGraphicsDeviceManager parent.SetWindowSizeAndFormat(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferFormat, graphics.PreferredDepthStencilFormat); }
internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host) { this.parent = parent; this.logic = logic; this.control = host; System.Windows.Forms.Control parentControl = this.control; while (parentControl != null) { if (parentControl is System.Windows.Forms.Form) { this.parentForm = (System.Windows.Forms.Form)parentControl; break; } parentControl = parentControl.Parent; } if (parentForm == null) { throw new ArgumentException("Unable to find Parent Form for display handle"); } parentForm.MouseWheel += new System.Windows.Forms.MouseEventHandler(parentControl_MouseWheel); parentForm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(parentForm_FormClosed); formsDeviceService = new WinFormsHostGraphicsDeviceService(this, this.control.ClientSize.Width, this.control.ClientSize.Height); services = new GameServiceContainer(); services.AddService(typeof(IGraphicsDeviceService), formsDeviceService); services.AddService(typeof(IGraphicsDeviceManager), formsDeviceService); presentation = RenderTargetUsage.PlatformContents; content = new ContentManager(services); int width = 0; int height = 0; SurfaceFormat format = SurfaceFormat.Color; width = control.ClientSize.Width; height = control.ClientSize.Height; parent.SetWindowSizeAndFormat(width, height, format, DepthFormat.Depth24Stencil8); parent.SetupGraphicsDeviceManager(null, ref presentation); formsDeviceService.CreateDevice(presentation, host); host.SetApplication(parent, this, formsDeviceService); host.BeginInvoke((EventHandler) delegate { parent.SetGraphicsDevice(GraphicsDevice); logic.Initialise(); logic.LoadContent(); }); }
internal XNAGameComponentHostAppWrapper(XNALogic logic, Application parent, GameComponentHost host) { this.parent = parent; this.logic = logic; this.control = host; this.game = host.Game; content = new ContentManager(game.Services); UpdateWindowSize(); host.DrawEvent += new GameEvent(host_Draw); host.UpdateEvent += new GameEvent(host_Update); host.InitaliseEvent += new GameEvent(host_InitaliseEvent); }
/// <summary> /// Start the main application loop. This method should be called from the entry point of the application /// </summary> public void Run() { if (xnaLogic != null) { throw new InvalidOperationException("Application is already initalised"); } xnaLogic = new XNALogic(this, IntPtr.Zero, out gamerServicesComponent); xnaLogic.Services.AddService(typeof(ApplicationProviderService), new ApplicationProviderService(this)); xnaLogic.Exiting += new EventHandler(ShutdownThreadPool); xnaLogic.Content.RootDirectory += @"\Content"; content = new ContentRegister(this, xnaLogic.Content); content.Add(this); xnaLogic.Run(); }
internal void Run(GameComponentHost host) { if (host == null) { throw new ArgumentNullException(); } if (xnaLogic != null) { throw new InvalidOperationException("Application is already initalised"); } xnaLogic = new XNALogic(this, host, out this.gamerServicesComponent); xnaLogic.Services.AddService(typeof(ApplicationProviderService), new ApplicationProviderService(this)); xnaLogic.Exiting += new EventHandler(ShutdownThreadPool); xnaLogic.Content.RootDirectory += @"\Content"; content = new ContentRegister(this, xnaLogic.Content); content.Add(this); xnaLogic.Run(); }
internal void Run(GameComponentHost host) { if (host == null) throw new ArgumentNullException(); if (xnaLogic != null) throw new InvalidOperationException("Application is already initalised"); xnaLogic = new XNALogic(this, host, out this.gamerServicesComponent); xnaLogic.Services.AddService(typeof(ApplicationProviderService), new ApplicationProviderService(this)); xnaLogic.Exiting += new EventHandler(ShutdownThreadPool); xnaLogic.Content.RootDirectory += "Content"; content = new ContentRegister(this, xnaLogic.Content); content.Add(this); xnaLogic.Run(); }
/// <summary> /// Start the main application loop. This method should be called from the entry point of the application /// </summary> public void Run() { if (xnaLogic != null) throw new InvalidOperationException("Application is already initalised"); xnaLogic = new XNALogic(this, null, out gamerServicesComponent); this.XnaComponents.ComponentAdded += delegate(object sender, GameComponentCollectionEventArgs e) { if (e.GameComponent is DrawableGameComponent) drawableComponents++; }; this.XnaComponents.ComponentRemoved += delegate(object sender,GameComponentCollectionEventArgs e) { if (e.GameComponent is DrawableGameComponent) drawableComponents--; }; xnaLogic.Services.AddService(typeof(ApplicationProviderService), new ApplicationProviderService(this)); xnaLogic.Exiting += new EventHandler(ShutdownThreadPool); xnaLogic.Content.RootDirectory += "Content"; content = new ContentRegister(this, xnaLogic.Content); content.Add(this); xnaLogic.Run(); }
internal XNAGameAppWrapper(XNALogic logic, Application parent, out Microsoft.Xna.Framework.GamerServices.GamerServicesComponent gamerServicesComponent) { this.parent = parent; this.logic = logic; graphics = new GraphicsDeviceManager(this); graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(PreparingDeviceSettings); graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; graphics.SynchronizeWithVerticalRetrace = true; graphics.GraphicsProfile = GraphicsProfile.HiDef; gamerServicesComponent = null; if (parent.ApplicationRequiresGamerServices) { if (gamerServicesRegistered) throw new InvalidOperationException("This sample requires the GamerServices component.\nUnfortunately, XNA does not let you create this component more than once in a session.\nPlease restart the application"); gamerServicesRegistered = true; gamerServicesComponent = new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent((Game)this); this.Components.Add(gamerServicesComponent); } #if DEBUG #if !XBOX360 Window.Title += " [XEN DEBUG API - XNA 4 FX]"; #endif #endif presentation = RenderTargetUsage.PlatformContents; parent.SetWindowSizeAndFormat(graphics.PreferredBackBufferWidth,graphics.PreferredBackBufferHeight,graphics.PreferredBackBufferFormat, graphics.PreferredDepthStencilFormat); parent.SetupGraphicsDeviceManager(graphics, ref presentation); //values may have changed in SetupGraphicsDeviceManager parent.SetWindowSizeAndFormat(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferFormat, graphics.PreferredDepthStencilFormat); }
internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host) { this.parent = parent; this.logic = logic; this.control = host; System.Windows.Forms.Control parentControl = this.control; while (parentControl != null) { if (parentControl is System.Windows.Forms.Form) { this.parentForm = (System.Windows.Forms.Form)parentControl; break; } parentControl = parentControl.Parent; } if (parentForm == null) throw new ArgumentException("Unable to find Parent Form for display handle"); parentForm.MouseWheel += new System.Windows.Forms.MouseEventHandler(parentControl_MouseWheel); parentForm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(parentForm_FormClosed); formsDeviceService = new WinFormsHostGraphicsDeviceService(this, this.control.ClientSize.Width, this.control.ClientSize.Height); services = new GameServiceContainer(); services.AddService(typeof(IGraphicsDeviceService), formsDeviceService); services.AddService(typeof(IGraphicsDeviceManager), formsDeviceService); presentation = RenderTargetUsage.PlatformContents; content = new ContentManager(services); int width = 0; int height = 0; SurfaceFormat format = SurfaceFormat.Color; width = control.ClientSize.Width; height = control.ClientSize.Height; parent.SetWindowSizeAndFormat(width, height, format, DepthFormat.Depth24Stencil8); parent.SetupGraphicsDeviceManager(null, ref presentation); formsDeviceService.CreateDevice(presentation, host); host.SetApplication(parent, this, formsDeviceService); host.BeginInvoke((EventHandler)delegate { parent.SetGraphicsDevice(GraphicsDevice); logic.Initialise(); logic.LoadContent(); }); }