Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GamePlatformWindowsRuntime.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 //
4 // Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 #if SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
24 using System.Collections.Generic;
25 
26 using SiliconStudio.Paradox.Graphics;
27 using Windows.ApplicationModel;
28 
29 namespace SiliconStudio.Paradox.Games
30 {
31  internal class GamePlatformWindowsRuntime : GamePlatform
32  {
33  public GamePlatformWindowsRuntime(GameBase game) : base(game)
34  {
35  }
36 
37  public override string DefaultAppDirectory
38  {
39  get
40  {
41  return Package.Current.InstalledLocation.Path;
42  }
43  }
44 
45  internal override GameWindow[] GetSupportedGameWindows()
46  {
47  return new GameWindow[]
48  {
49  new GameWindowWindowsRuntimeSwapChainPanel(),
50  };
51  }
52 
53  public override List<GraphicsDeviceInformation> FindBestDevices(GameGraphicsParameters preferredParameters)
54  {
55  var graphicsDeviceInfos = base.FindBestDevices(preferredParameters);
56 
57  // Special case where the default FindBestDevices is not working
58  if (graphicsDeviceInfos.Count == 0)
59  {
60  var graphicsAdapter = GraphicsAdapterFactory.Adapters[0];
61 
62  // Iterate on each preferred graphics profile
63  foreach (var featureLevel in preferredParameters.PreferredGraphicsProfile)
64  {
65  // Check if this profile is supported.
66  if (graphicsAdapter.IsProfileSupported(featureLevel))
67  {
68  var deviceInfo = new GraphicsDeviceInformation
69  {
70  Adapter = graphicsAdapter,
71  GraphicsProfile = featureLevel,
72  PresentationParameters =
73  {
74  MultiSampleCount = MSAALevel.None,
75  IsFullScreen = preferredParameters.IsFullScreen,
76  PresentationInterval = preferredParameters.SynchronizeWithVerticalRetrace ? PresentInterval.One : PresentInterval.Immediate,
77  DeviceWindowHandle = MainWindow.NativeWindow,
78  }
79  };
80 
81  // Hardcoded format and refresh rate...
82  // This is a workaround to allow this code to work inside the emulator
83  // but this is not really robust
84  // TODO: Check how to handle this case properly
85  var displayMode = new DisplayMode(PixelFormat.B8G8R8A8_UNorm, gameWindow.ClientBounds.Width, gameWindow.ClientBounds.Height, new Rational(60, 1));
86  AddDevice(displayMode, deviceInfo, preferredParameters, graphicsDeviceInfos);
87 
88  // If the profile is supported, we are just using the first best one
89  break;
90  }
91  }
92  }
93 
94  return graphicsDeviceInfos;
95  }
96  }
97 }
98 #endif
GraphicsProfile
Identifies the set of supported devices for the demo based on device capabilities.
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32