예제 #1
0
        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);
        }
예제 #2
0
        internal XNALogic(Application parent, object host, out Microsoft.Xna.Framework.GamerServices.GamerServicesComponent gamerServicesComponent)
        {
            this.state  = new AppState(parent);
            this.parent = parent;

            parent.UpdateManager.Add(state);
            parent.UpdateManager.Add(parent);

            gamerServicesComponent = null;

            if (host is GameComponentHost)
            {
                this.xnaGame = new XNAGameComponentHostAppWrapper(this, parent, host as GameComponentHost);
            }
            else
            {
#if !XBOX360
                if (host == null)
                {
                    this.xnaGame = new XNAGameAppWrapper(this, parent, out gamerServicesComponent);
                }
                else
                {
                    WinFormsHostControl _host = host as WinFormsHostControl;
                    if (_host != null)
                    {
                        this.xnaGame = new XNAWinFormsHostAppWrapper(this, parent, _host);
                    }
                    else
                    {
                        this.xnaGame = new XNAGameAppWrapper(this, parent, out gamerServicesComponent);
                    }
                }
#else
                this.xnaGame = new XNAGameAppWrapper(this, parent, out gamerServicesComponent);
#endif
            }

            this.Exiting += delegate
            {
                Xen.Graphics.Resource.ClearResourceTracking();
            };
        }
		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);
		}