本文整理汇总了C#中System.Factory.GetAdapterCount方法的典型用法代码示例。如果您正苦于以下问题:C# Factory.GetAdapterCount方法的具体用法?C# Factory.GetAdapterCount怎么用?C# Factory.GetAdapterCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Factory
的用法示例。
在下文中一共展示了Factory.GetAdapterCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public static void Initialize( out Factory dxgiFactory, out SlimDX.Direct3D11.Device d3d11Device )
{
dxgiFactory = new Factory();
Adapter adapter = null;
long videoMemory = 0;
for ( var i = 0; i < dxgiFactory.GetAdapterCount(); i++ )
{
var tmpAdapter = dxgiFactory.GetAdapter( i );
if ( tmpAdapter.Description.DedicatedVideoMemory > videoMemory )
{
adapter = tmpAdapter;
videoMemory = tmpAdapter.Description.DedicatedVideoMemory;
}
}
d3d11Device = null;
try
{
d3d11Device = Constants.DEBUG_D3D11_DEVICE
? new SlimDX.Direct3D11.Device( adapter,
DeviceCreationFlags.Debug,
new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } )
: new SlimDX.Direct3D11.Device( adapter,
DeviceCreationFlags.None,
new[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1, FeatureLevel.Level_10_0 } );
}
catch ( Exception e )
{
Console.WriteLine( "\nError: Couldn't create Direct3D 11 device (exception: " + e.Source + ", " + e.Message + ").\n" );
}
}
示例2: PrintAdapters
private static void PrintAdapters(Factory factory) {
var adapterCount = factory.GetAdapterCount();
for (var adapterIndex = 0; adapterIndex < adapterCount; ++adapterIndex) {
using (var adapter = factory.GetAdapter(adapterIndex)) {
Console.WriteLine("Adapter Index: {0}", adapterIndex);
foreach (var descProperty in adapter.Description.GetType().GetProperties()) {
Console.WriteLine(" {0}: {1}", ParseName(descProperty.Name), descProperty.GetValue(adapter.Description, null));
}
PrintAdapterOutputs(adapter);
PrintDeviceInformation(adapter);
}
}
}