Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        protected void ShowAdapterInfo(GraphicsParameters parameters)
        {
            Log.Message("Mode : {0}x{1} {3} MS:{2} Stereo:{5} {4}",
                        parameters.Width,
                        parameters.Height,
                        0,
                        parameters.FullScreen ? "FS" : "W",
                        parameters.UseDebugDevice ? "(Debug)" : "",
                        parameters.StereoMode);

            using (var factory2 = new Factory1()) {
                Log.Message("Adapters:");

                try {
                    foreach (var adapter in factory2.Adapters)
                    {
                        var aDesc = adapter.Description;
                        Log.Message("   {0} - {1}", aDesc.Description, D3D.Device.GetSupportedFeatureLevel(adapter));

                        foreach (var output in adapter.Outputs)
                        {
                            var desc       = output.Description;
                            var bnds       = output.Description.DesktopBounds;
                            var bndsString = string.Format("x:{0} y:{1} w:{2} h:{3}", bnds.Left, bnds.Top, bnds.Right - bnds.Left, bnds.Bottom - bnds.Top);

                            Log.Message("   {0} [{1}] {2}", desc.DeviceName, bndsString, desc.Rotation);
                        }
                    }
                } catch (Exception e) {
                    Log.Warning(e.Message);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public BaseDisplay(Game game, GraphicsDevice device, GraphicsParameters parameters) : base(device)
        {
            this.Game = game;

            ShowAdapterInfo(parameters);

            Game.Reloading += (s, e) => LoadContent();
        }
Esempio n. 3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public GenericDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			try {
				window = CreateTouchForm(parameters, null);
			}
			catch (System.EntryPointNotFoundException e) {
				Log.Warning("Looks like your system does't support touch gestures. You need Windows 8.1 or newer for this.");
				window = CreateForm(parameters, null);
			}

			try {
				NvApi.Initialize();
				NvApi.Stereo_Disable();
			}
			catch (NVException nvex) {
				Log.Debug(nvex.Message);
			}

			var deviceFlags			=	DeviceCreationFlags.BgraSupport;
				//deviceFlags			|=	DeviceCreationFlags.SingleThreaded;
				deviceFlags			|=	parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

			var driverType			=	DriverType.Hardware;

			var featureLevel	=	HardwareProfileChecker.GetFeatureLevel( parameters.GraphicsProfile ); 


			swapChainDesc = new SwapChainDescription () {
				BufferCount			=	1,	// UE4 use this.
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};

			D3D.Device.CreateWithSwapChain( driverType, deviceFlags, new[]{ featureLevel }, swapChainDesc, out d3dDevice, out swapChain );

			//Log.Message("   compute shaders : {0}", d3dDevice.CheckFeatureSupport(Feature.ComputeShaders) );
			//Log.Message("   shader doubles  : {0}", d3dDevice.CheckFeatureSupport(Feature.ShaderDoubles) );
			//Log.Message("   threading       : {0}", d3dDevice.CheckFeatureSupport(Feature.Threading) );
			bool driverConcurrentCreates;
			bool driverCommandLists;
			d3dDevice.CheckThreadingSupport( out driverConcurrentCreates, out driverCommandLists );
			//d3dDevice.GetCounterCapabilities();
			Log.Message("   Concurrent Creates : {0}", driverConcurrentCreates );
			Log.Message("   Command Lists      : {0}", driverCommandLists );


			var factory		=	swapChain.GetParent<Factory>();
			factory.MakeWindowAssociation( window.Handle, WindowAssociationFlags.IgnoreAll );


			clientWidth		=	window.ClientSize.Width;
			clientHeight	=	window.ClientSize.Height;
		}
Esempio n. 4
0
 /// <summary>
 /// Applies graphics parameters.
 /// </summary>
 /// <param name="p"></param>
 internal void ApplyParameters(ref GraphicsParameters p)
 {
     p.Width           = Width;
     p.Height          = Height;
     p.FullScreen      = Fullscreen;
     p.StereoMode      = (Fusion.Drivers.Graphics.StereoMode)StereoMode;
     p.InterlacingMode = (Fusion.Drivers.Graphics.InterlacingMode)InterlacingMode;
     p.UseDebugDevice  = UseDebugDevice;
     p.MsaaLevel       = 1;
 }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="game"></param>
        /// <param name="device"></param>
        /// <param name="parameters"></param>
        public OculusRiftDisplay(Game game, GraphicsDevice device, GraphicsParameters parameters) : base(game, device, parameters)
        {
            oculus = new Wrap();

            // Initialize the Oculus runtime.
            oculus.Initialize();

            OVR.GraphicsLuid graphicsLuid;
            hmd = oculus.Hmd_Create(out graphicsLuid);

            if (hmd == null)
            {
                MessageBox.Show("Oculus Rift not detected.", "Uh oh", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (hmd.ProductName == string.Empty)
            {
                MessageBox.Show("The HMD is not enabled.", "There's a tear in the Rift", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            parameters.Width  = hmd.Resolution.Width;
            parameters.Height = hmd.Resolution.Height;

            window = CreateForm(parameters, null, false);

            var deviceFlags = DeviceCreationFlags.None;

            deviceFlags |= parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

            var driverType = DriverType.Hardware;

            var featureLevel = HardwareProfileChecker.GetFeatureLevel(parameters.GraphicsProfile);


            var swapChainDesc = new SwapChainDescription {
                BufferCount       = 1,
                ModeDescription   = new ModeDescription(hmd.Resolution.Width, hmd.Resolution.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = window.Handle,
                SampleDescription = new SampleDescription(parameters.MsaaLevel, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput | Usage.ShaderInput,
                Flags             = SwapChainFlags.None,
            };


            D3D.Device.CreateWithSwapChain(driverType, deviceFlags, new[] { featureLevel }, swapChainDesc, out d3dDevice, out swapChain);


            var myFactory = swapChain.GetParent <Factory>();

            myFactory.MakeWindowAssociation(window.Handle, WindowAssociationFlags.IgnoreAll);
        }
Esempio n. 6
0
        /// <summary>
        /// InitInternal
        /// </summary>
        internal bool InitInternal()
        {
            Log.Message("");
            Log.Message("-------- Game Initializing --------");

            var p = new GraphicsParameters();

            RenderSystem.ApplyParameters(ref p);

            //	going to fullscreen immediatly on startup lead to
            //	bugs and inconsistnecy for diferrent stereo modes,
            //	so we store fullscreen mode and apply it on next update step.
            requestFullscreenOnStartup = p.FullScreen;
            p.FullScreen = false;


            //	initialize drivers :
            GraphicsDevice.Initialize(p);
            InputDevice.Initialize();

            //	initiliaze core systems :
            Initialize(SoundSystem);
            Initialize(RenderSystem);
            Initialize(Keyboard);
            Initialize(Mouse);
            Initialize(Touch);

            //	initialize additional systems :
            Initialize(Console);
            Initialize(Frames);

            //	initialize game-specific systems :
            Initialize(UserInterface);
            Initialize(GameClient);
            Initialize(GameServer);
            Initialize(GameEditor);

            //	init game :
            Log.Message("");

            //	attach console sprite layer :
            Console.ConsoleSpriteLayer.Order = int.MaxValue / 2;
            RenderSystem.SpriteLayers.Add(Console.ConsoleSpriteLayer);

            Frames.FramesSpriteLayer.Order = int.MaxValue / 2 - 1;
            RenderSystem.SpriteLayers.Add(Frames.FramesSpriteLayer);

            initialized = true;

            Log.Message("-----------------------------------------");
            Log.Message("");

            return(true);
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="game"></param>
		/// <param name="device"></param>
		/// <param name="parameters"></param>
		public OculusRiftDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			oculus = new Wrap();

			// Initialize the Oculus runtime.
			oculus.Initialize();

			OVR.GraphicsLuid graphicsLuid;
			hmd = oculus.Hmd_Create(out graphicsLuid);

			if (hmd == null) {
				MessageBox.Show("Oculus Rift not detected.", "Uh oh", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			if (hmd.ProductName == string.Empty)
				MessageBox.Show("The HMD is not enabled.", "There's a tear in the Rift", MessageBoxButtons.OK, MessageBoxIcon.Error);


			parameters.Width	= hmd.Resolution.Width;
			parameters.Height	= hmd.Resolution.Height;

			window = CreateForm(parameters, null);

			var deviceFlags = DeviceCreationFlags.None;
			deviceFlags |= parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

			var driverType = DriverType.Hardware;

			var featureLevel = HardwareProfileChecker.GetFeatureLevel(parameters.GraphicsProfile);


			var swapChainDesc = new SwapChainDescription {
				BufferCount			= 1,
				ModeDescription		= new ModeDescription(hmd.Resolution.Width, hmd.Resolution.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
				IsWindowed			= true,
				OutputHandle		= window.Handle,
				SampleDescription	= new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			= SwapEffect.Discard,
				Usage				= Usage.RenderTargetOutput| Usage.ShaderInput,
				Flags				= SwapChainFlags.None,
			};


			D3D.Device.CreateWithSwapChain(driverType, deviceFlags, new[] { featureLevel }, swapChainDesc, out d3dDevice, out swapChain);


			var myFactory = swapChain.GetParent<Factory>();
			myFactory.MakeWindowAssociation(window.Handle, WindowAssociationFlags.IgnoreAll);
		}
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public StereoInterlacedDisplay(Game game, GraphicsDevice device, GraphicsParameters parameters) : base(game, device, parameters)
        {
            try {
                NvApi.Initialize();
                NvApi.Stereo_Disable();
            }
            catch (NVException nvex) {
                Log.Debug(nvex.Message);
            }


            window = CreateForm(parameters, null, false);

            var deviceFlags = DeviceCreationFlags.None;

            deviceFlags |= parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

            var driverType = DriverType.Hardware;

            var featureLevel = HardwareProfileChecker.GetFeatureLevel(parameters.GraphicsProfile);


            swapChainDesc = new SwapChainDescription()
            {
                BufferCount       = 1,
                ModeDescription   = new ModeDescription(parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = window.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None,
            };


            D3D.Device.CreateWithSwapChain(driverType, deviceFlags, new[] { featureLevel }, swapChainDesc, out d3dDevice, out swapChain);


            var factory = swapChain.GetParent <Factory>();

            factory.MakeWindowAssociation(window.Handle, WindowAssociationFlags.IgnoreAll);


            clientWidth  = window.ClientSize.Width;
            clientHeight = window.ClientSize.Height;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public StereoInterlacedDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			try {
				NvApi.Initialize();
				NvApi.Stereo_Disable();
			}
			catch (NVException nvex) {
				Log.Debug(nvex.Message);
			}


			window	=	CreateForm( parameters, null );

			var deviceFlags			=	DeviceCreationFlags.None;
				deviceFlags			|=	parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

			var driverType			=	DriverType.Hardware;

			var featureLevel	=	HardwareProfileChecker.GetFeatureLevel( parameters.GraphicsProfile ); 


			swapChainDesc = new SwapChainDescription () {
				BufferCount			=	1,
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window.Handle,
				SampleDescription	=	new SampleDescription(1, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};


			D3D.Device.CreateWithSwapChain( driverType, deviceFlags, new[]{ featureLevel }, swapChainDesc, out d3dDevice, out swapChain );


			var factory		=	swapChain.GetParent<Factory>();
			factory.MakeWindowAssociation( window.Handle, WindowAssociationFlags.IgnoreAll );


			clientWidth		=	window.ClientSize.Width;
			clientHeight	=	window.ClientSize.Height;
		}
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public StereoDualHeadDisplay(Game game, GraphicsDevice device, GraphicsParameters parameters) : base(game, device, parameters)
        {
            try {
                NvApi.Initialize();
                NvApi.Stereo_Disable();
            }
            catch (NVException nvex) {
                Log.Debug(nvex.Message);
            }

            var featureLevel = HardwareProfileChecker.GetFeatureLevel(parameters.GraphicsProfile);

            Adapter adapter;
            Output  leftOut, rightOut;

            GetDualHeadAdapter(featureLevel, out adapter, out leftOut, out rightOut);



            window1     = CreateForm(parameters, leftOut, false);
            window2     = CreateForm(parameters, rightOut, false);
            window1.Tag = leftOut.Description;
            window2.Tag = rightOut.Description;

            window1.AddOwnedForm(window2);

            window2.Show();
            window1.Show();

            window1.Resize    += window_Resize;
            window2.Resize    += window_Resize;
            window1.Move      += window_Move;
            window2.Move      += window_Move;
            window1.Activated += window_Activated;
            window2.Activated += window_Activated;
            targetForm         = window1;



            var deviceFlags = DeviceCreationFlags.None;

            deviceFlags |= parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;


            swapChainDesc1 = new SwapChainDescription()
            {
                BufferCount       = 1,
                ModeDescription   = new ModeDescription(parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = window1.Handle,
                SampleDescription = new SampleDescription(parameters.MsaaLevel, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None,
            };

            swapChainDesc2 = new SwapChainDescription()
            {
                BufferCount       = 1,
                ModeDescription   = new ModeDescription(parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = window2.Handle,
                SampleDescription = new SampleDescription(parameters.MsaaLevel, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None,
            };


            d3dDevice = new D3D.Device(adapter, deviceFlags, featureLevel);


            using (var factory = adapter.GetParent <Factory>()) {
                swapChain1 = new SwapChain(factory, d3dDevice, swapChainDesc1);
                swapChain2 = new SwapChain(factory, d3dDevice, swapChainDesc2);

                //factory.MakeWindowAssociation( new IntPtr(0), WindowAssociationFlags.None );
                factory.MakeWindowAssociation(window1.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter);
                factory.MakeWindowAssociation(window2.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter);
            }


            clientWidth  = window1.ClientSize.Width;
            clientHeight = window1.ClientSize.Height;

            fullscr = parameters.FullScreen;
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public NV3DVisionDisplay(Game game, GraphicsDevice device, GraphicsParameters parameters) : base(game, device, parameters)
        {
            Log.Message("Using NVidia 3D Vision");

            //
            //	Init NV API and enable stereo :
            //
            NvApi.Initialize();
            NvApi.Stereo_Enable();
            NvApi.Stereo_SetDriverMode(NvStereoDriverMode.Direct);


            //
            //	Create main window
            //
            window = CreateForm(parameters, null, false);


            var deviceFlags = DeviceCreationFlags.None;

            deviceFlags |= parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

            var driverType = DriverType.Hardware;

            var featureLevel = HardwareProfileChecker.GetFeatureLevel(parameters.GraphicsProfile);


            swapChainDesc = new SwapChainDescription()
            {
                BufferCount       = 1,
                ModeDescription   = new ModeDescription(parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = window.Handle,
                SampleDescription = new SampleDescription(parameters.MsaaLevel, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None,
            };


            //
            //	Create device :
            //
            D3D.Device.CreateWithSwapChain(driverType, deviceFlags, new[] { featureLevel }, swapChainDesc, out d3dDevice, out swapChain);


            var factory = swapChain.GetParent <Factory>();

            factory.MakeWindowAssociation(window.Handle, WindowAssociationFlags.IgnoreAll);


            clientWidth  = window.ClientSize.Width;
            clientHeight = window.ClientSize.Height;


            //
            //	Setup 3DVision :
            //

            try {
                stereoHandle = NvApi.Stereo_CreateHandleFromIUnknown(d3dDevice.NativePointer);

                NvApi.Stereo_Activate(stereoHandle);
                NvApi.Stereo_SetActiveEye(stereoHandle, NvStereoActiveEye.Mono);
            } catch (NVException) {
                SafeDispose(ref d3dDevice);
                SafeDispose(ref swapChain);
                throw;
            }
        }
Esempio n. 12
0
		/// <summary>
		/// 
		/// </summary>
		protected void ShowAdapterInfo ( GraphicsParameters parameters )
		{
			Log.Message("Mode : {0}x{1} {3} MS:{2} Stereo:{5} {4}", 
				parameters.Width, 
				parameters.Height, 
				0,
				parameters.FullScreen ? "FS" : "W", 
				parameters.UseDebugDevice ? "(Debug)" : "",
				parameters.StereoMode );

			using ( var factory2 = new Factory() ) {

				Log.Message("Adapters:");

				try {
					foreach (var adapter in factory2.Adapters) {
						var aDesc = adapter.Description;
						Log.Message("   {0} - {1}", aDesc.Description, D3D.Device.GetSupportedFeatureLevel(adapter));
					
						foreach ( var output in adapter.Outputs ) {
							var desc = output.Description;
							var bnds = output.Description.DesktopBounds;
							var bndsString = string.Format("x:{0} y:{1} w:{2} h:{3}", bnds.Left, bnds.Top, bnds.Right-bnds.Left, bnds.Bottom-bnds.Top );

							Log.Message("   {0} [{1}] {2}", desc.DeviceName, bndsString, desc.Rotation );
						}
					}
				} catch ( Exception e ) {
					Log.Warning( e.Message );
				}
			}
		}
Esempio n. 13
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public BaseDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base(device)
		{
			this.Game	=	game;

			ShowAdapterInfo( parameters );
		}
Esempio n. 14
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		/// <param name="output"></param>
		/// <returns></returns>
		public Form CreateTouchForm(GraphicsParameters parameters, Output output)
		{
			var form = new TouchForm() {
				Text			=	Game.GameTitle,
				BackColor		=	System.Drawing.Color.Black,
				ClientSize		=	new System.Drawing.Size(parameters.Width, parameters.Height),
				Icon			=	Game.Icon ?? Fusion.Properties.Resources.fusionIcon,
				ControlBox		=	false,
				StartPosition	=	output == null ? FormStartPosition.CenterScreen : FormStartPosition.Manual,
			};


			if (output != null) {
				var bounds	= output.Description.DesktopBounds;
				var scrW	= bounds.Right - bounds.Left;
				var scrH	= bounds.Bottom - bounds.Top;

				form.Location = new System.Drawing.Point(bounds.Left + (scrW - form.Width) / 2, bounds.Top + (scrH - form.Height) / 2);
				form.Text += " - [" + output.Description.DeviceName + "]";
			}

			form.KeyDown	+= form_KeyDown;
			form.KeyUp		+= form_KeyUp;
			form.KeyPress	+= form_KeyPress;
			form.Resize		+= (s, e) => Game.InputDevice.RemoveAllPressedKeys();
			form.Move		+= (s, e) => Game.InputDevice.RemoveAllPressedKeys();

			form.TouchTap			+= (pos) => Game.InputDevice.NotifyTouchTap(pos);
			form.TouchDoubleTap		+= (pos) => Game.InputDevice.NotifyTouchDoubleTap(pos);
			form.TouchSecondaryTap	+= (pos) => Game.InputDevice.NotifyTouchSecondaryTap(pos);
			form.TouchManipulation	+= (center, delta, scale) => Game.InputDevice.NotifyTouchManipulation(center, delta, scale);

			return form;
		}
Esempio n. 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public GenericDisplay(Game game, GraphicsDevice device, GraphicsParameters parameters) : base(game, device, parameters)
        {
            try {
                window = CreateForm(parameters, null, true);
            }
            catch (System.EntryPointNotFoundException) {
                Log.Warning("Looks like your system does't support touch gestures. You need Windows 8.1 or newer for this.");
                window = CreateForm(parameters, null, false);
            }

            try {
                NvApi.Initialize();
                NvApi.Stereo_Disable();
            }
            catch (NVException nvex) {
                Log.Debug(nvex.Message);
            }

            var deviceFlags = DeviceCreationFlags.BgraSupport;

            //deviceFlags			|=	DeviceCreationFlags.SingleThreaded;
            deviceFlags |= parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

            var driverType = DriverType.Hardware;

            var featureLevel = HardwareProfileChecker.GetFeatureLevel(parameters.GraphicsProfile);


            swapChainDesc = new SwapChainDescription()
            {
                BufferCount       = 1,                                          // UE4 use this.
                ModeDescription   = new ModeDescription(parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = window.Handle,
                SampleDescription = new SampleDescription(parameters.MsaaLevel, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None,
            };

            D3D.Device.CreateWithSwapChain(driverType, deviceFlags, new[] { featureLevel }, swapChainDesc, out d3dDevice, out swapChain);

            //Log.Message("   compute shaders : {0}", d3dDevice.CheckFeatureSupport(Feature.ComputeShaders) );
            //Log.Message("   shader doubles  : {0}", d3dDevice.CheckFeatureSupport(Feature.ShaderDoubles) );
            //Log.Message("   threading       : {0}", d3dDevice.CheckFeatureSupport(Feature.Threading) );
            bool driverConcurrentCreates;
            bool driverCommandLists;

            d3dDevice.CheckThreadingSupport(out driverConcurrentCreates, out driverCommandLists);
            //d3dDevice.GetCounterCapabilities();
            Log.Message("   Concurrent Creates : {0}", driverConcurrentCreates);
            Log.Message("   Command Lists      : {0}", driverCommandLists);


            var factory = swapChain.GetParent <Factory>();

            factory.MakeWindowAssociation(window.Handle, WindowAssociationFlags.IgnoreAll);


            clientWidth  = window.ClientSize.Width;
            clientHeight = window.ClientSize.Height;

            fullscr = parameters.FullScreen;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public StereoDualHeadDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			try {
				NvApi.Initialize();
				NvApi.Stereo_Disable();
			}
			catch (NVException nvex) {
				Log.Debug(nvex.Message);
			}

			var featureLevel	=	HardwareProfileChecker.GetFeatureLevel( parameters.GraphicsProfile ); 

			Adapter	adapter;
			Output leftOut, rightOut;

			GetDualHeadAdapter( featureLevel, out adapter, out leftOut, out rightOut );
			


			window1	=	CreateForm( parameters, leftOut );
			window2	=	CreateForm( parameters, rightOut );
			window1.Tag	=	leftOut.Description;
			window2.Tag	=	rightOut.Description;

			window1.AddOwnedForm( window2 );

			window2.Show();
			window1.Show();

			window1.Resize += window_Resize;
			window2.Resize += window_Resize;
			window1.Move += window_Move;	
			window2.Move += window_Move;
			window1.Activated += window_Activated;
			window2.Activated += window_Activated;
			targetForm	=	window1;



			var deviceFlags			=	DeviceCreationFlags.None;
				deviceFlags			|=	parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;


			swapChainDesc1 = new SwapChainDescription () {
				BufferCount			=	1,
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window1.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};

			swapChainDesc2 = new SwapChainDescription () {
				BufferCount			=	1,
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window2.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};


			d3dDevice	=	new D3D.Device( adapter, deviceFlags, featureLevel );


			using ( var factory = adapter.GetParent<Factory>() ) {
			
				swapChain1	=	new SwapChain( factory, d3dDevice, swapChainDesc1 );
				swapChain2	=	new SwapChain( factory, d3dDevice, swapChainDesc2 );

				//factory.MakeWindowAssociation( new IntPtr(0), WindowAssociationFlags.None );
				factory.MakeWindowAssociation( window1.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter );
				factory.MakeWindowAssociation( window2.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter );
			}


			clientWidth		=	window1.ClientSize.Width;
			clientHeight	=	window1.ClientSize.Height;
		}
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public Form CreateForm(GraphicsParameters parameters, Output output, bool supportTouch)
        {
            Form      form      = null;
            TouchForm touchForm = null;

            var text       = Game.GameTitle;
            var color      = System.Drawing.Color.Black;
            var clientSize = new System.Drawing.Size(parameters.Width, parameters.Height);
            var icon       = Game.Icon ?? Fusion.Properties.Resources.fusionIcon;
            var controlBox = false;
            var startPos   = output == null ? FormStartPosition.CenterScreen : FormStartPosition.Manual;

            //var windowState	=	parameters.FullScreen ? FormWindowState.Maximized : FormWindowState.Normal;
            //var border		=	parameters.FullScreen ? FormBorderStyle.None : FormBorderStyle.Sizable;

            var windowState = FormWindowState.Normal;
            var border      = FormBorderStyle.Sizable;


            if (supportTouch)
            {
                touchForm = new TouchForm()
                {
                    Text            = text,
                    BackColor       = color,
                    ClientSize      = clientSize,
                    Icon            = icon,
                    ControlBox      = controlBox,
                    StartPosition   = startPos,
                    WindowState     = windowState,
                    FormBorderStyle = border,
                };
                form = touchForm;
            }
            else
            {
                form = new Form()
                {
                    Text            = text,
                    BackColor       = color,
                    ClientSize      = clientSize,
                    Icon            = icon,
                    ControlBox      = controlBox,
                    StartPosition   = startPos,
                    WindowState     = windowState,
                    FormBorderStyle = border,
                };
            }


            if (output != null)
            {
                var bounds = output.Description.DesktopBounds;
                var scrW   = bounds.Right - bounds.Left;
                var scrH   = bounds.Bottom - bounds.Top;

                form.Location = new System.Drawing.Point(bounds.Left + (scrW - form.Width) / 2, bounds.Top + (scrH - form.Height) / 2);
                form.Text    += " - [" + output.Description.DeviceName + "]";
            }

                        #if false
            form.MouseDown += Form_MouseDown;
                        #endif

            form.KeyDown     += form_KeyDown;
            form.KeyUp       += form_KeyUp;
            form.KeyPress    += form_KeyPress;
            form.Resize      += (s, e) => Game.InputDevice.RemoveAllPressedKeys();
            form.Move        += (s, e) => Game.InputDevice.RemoveAllPressedKeys();
            form.FormClosing += form_FormClosing;

            if (supportTouch)
            {
                touchForm.PointerUp          += (s, e) => Game.Touch.CallPointerUpEvent(e.PointerID, e.Location);
                touchForm.PointerDown        += (s, e) => Game.Touch.CallPointerDownEvent(e.PointerID, e.Location);
                touchForm.PointerUpdate      += (s, e) => Game.Touch.CallPointerUpdateEvent(e.PointerID, e.Location);
                touchForm.PointerLostCapture += (s, e) => Game.Touch.CallPointerLostCapture();
            }

            ChangeFullscreen(form, parameters.FullScreen);

            return(form);
        }
Esempio n. 18
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public NV3DVisionDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			Log.Message("Using NVidia 3D Vision");

			//
			//	Init NV API and enable stereo :
			//	
			NvApi.Initialize();
			NvApi.Stereo_Enable();
			NvApi.Stereo_SetDriverMode( NvStereoDriverMode.Direct );


			//
			//	Create main window
			//	
			window	=	CreateForm( parameters, null );


			var deviceFlags			=	DeviceCreationFlags.None;
				deviceFlags			|=	parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;

			var driverType			=	DriverType.Hardware;

			var featureLevel	=	HardwareProfileChecker.GetFeatureLevel( parameters.GraphicsProfile ); 


			swapChainDesc = new SwapChainDescription () {
				BufferCount			=	1,
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};


			//
			//	Create device :
			//
			D3D.Device.CreateWithSwapChain( driverType, deviceFlags, new[]{ featureLevel }, swapChainDesc, out d3dDevice, out swapChain );


			var factory		=	swapChain.GetParent<Factory>();
			factory.MakeWindowAssociation( window.Handle, WindowAssociationFlags.IgnoreAll );


			clientWidth		=	window.ClientSize.Width;
			clientHeight	=	window.ClientSize.Height;


			//
			//	Setup 3DVision :
			//

			try {
				stereoHandle	=	NvApi.Stereo_CreateHandleFromIUnknown( d3dDevice.NativePointer );

				NvApi.Stereo_Activate( stereoHandle );
				NvApi.Stereo_SetActiveEye( stereoHandle, NvStereoActiveEye.Mono );

			} catch ( NVException ) {
				SafeDispose( ref d3dDevice );
				SafeDispose( ref swapChain );
				throw;
			}
		}