Jypeli  5
The simple game programming library
TargetedGraphicsDeviceManager.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System.Collections.Generic;
2 using Microsoft.Xna.Framework;
3 
4 namespace 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 }