source: 2014/24/EemeliK/Zombieland/Jypeli/Graphics/TargetedGraphicsDeviceManager.cs @ 5974

Revision 5974, 1.5 KB checked in by empaheik, 4 years ago (diff)
Line 
1using System.Collections.Generic;
2using Microsoft.Xna.Framework;
3
4namespace Jypeli
5{
6#if WINDOWS
7    // see: http://www.carbonatethis.com/archives/121
8    internal class TargetedGraphicsDeviceManager : GraphicsDeviceManager
9    {
10        private int target = 1;
11
12        public TargetedGraphicsDeviceManager( Game game, int displayTarget )
13            : base( game )
14        {
15            target = displayTarget;
16        }
17
18        protected override void OnPreparingDeviceSettings( object sender, PreparingDeviceSettingsEventArgs args )
19        {
20            //  args.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = 0;
21            args.GraphicsDeviceInformation.PresentationParameters.IsFullScreen = false;
22
23            base.OnPreparingDeviceSettings( sender, args );
24        }
25
26        protected override void RankDevices( List<GraphicsDeviceInformation> foundDevices )
27        {
28            List<GraphicsDeviceInformation> removals = new List<GraphicsDeviceInformation>();
29            for ( int i = 0; i < foundDevices.Count; i++ )
30            {
31                if ( !foundDevices[i].Adapter.DeviceName.Contains( "DISPLAY" + target ) )
32                    removals.Add( foundDevices[i] );
33            }
34            foreach ( GraphicsDeviceInformation info in removals )
35            {
36                foundDevices.Remove( info );
37            }
38
39            base.RankDevices( foundDevices );
40        }
41    }
42#endif
43}
Note: See TracBrowser for help on using the repository browser.