137 lines
4.3 KiB
C#
Raw Permalink Normal View History

2011-10-31 05:36:24 +00:00
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using ANX.Framework.NonXNA;
2012-10-10 19:26:53 +00:00
using ANX.Framework.NonXNA.Development;
2011-10-31 05:36:24 +00:00
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
2011-10-31 05:36:24 +00:00
namespace ANX.Framework.Graphics
{
2015-10-24 19:26:27 +02:00
[PercentageComplete(100)]
[Developer("Glatzemann, KorsarNek")]
2012-10-10 19:26:53 +00:00
[TestState(TestStateAttribute.TestState.Untested)]
2011-10-31 05:36:24 +00:00
public sealed class GraphicsAdapter
{
2015-10-24 19:26:27 +02:00
private static ReadOnlyCollection<GraphicsAdapter> _adapters;
public static ReadOnlyCollection<GraphicsAdapter> Adapters
{
get
{
if (_adapters == null)
{
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
_adapters = new ReadOnlyCollection<GraphicsAdapter>(creator.GetAdapterList().Select((x) => new GraphicsAdapter(x)).ToArray());
}
return _adapters;
}
}
public static GraphicsAdapter DefaultAdapter
{
get { return Adapters.First(a => a.IsDefaultAdapter); }
}
public static bool UseNullDevice { get; set; }
2015-10-24 19:26:27 +02:00
public static bool UseReferenceDevice { get; set; }
private INativeGraphicsAdapter nativeAdapter;
#region Public
public int DeviceId
{
get { return nativeAdapter.DeviceId; }
}
public string DeviceName
{
get { return nativeAdapter.DeviceName; }
}
public bool IsDefaultAdapter
{
get { return nativeAdapter.IsDefaultAdapter; }
}
public int Revision
{
get { return nativeAdapter.Revision; }
}
public int SubSystemId
{
get { return nativeAdapter.SubSystemId; }
}
public int VendorId
{
get { return nativeAdapter.VendorId; }
}
public string Description
{
get { return nativeAdapter.Description; }
}
public DisplayMode CurrentDisplayMode
{
get { return nativeAdapter.CurrentDisplayMode; }
}
public DisplayModeCollection SupportedDisplayModes
{
get { return nativeAdapter.SupportedDisplayModes; }
}
public IntPtr MonitorHandle
{
get { return nativeAdapter.MonitorHandle; }
}
public bool IsWideScreen
{
get
{
return this.CurrentDisplayMode.AspectRatio > (16 / 10);
}
}
#endregion
internal INativeGraphicsAdapter NativeAdapter
{
get { return nativeAdapter; }
}
internal GraphicsAdapter(INativeGraphicsAdapter nativeAdapter)
{
if (nativeAdapter == null)
throw new ArgumentNullException("nativeAdapter");
this.nativeAdapter = nativeAdapter;
2011-10-31 05:36:24 +00:00
}
public bool IsProfileSupported(GraphicsProfile graphicsProfile)
{
2015-10-24 19:26:27 +02:00
return nativeAdapter.IsProfileSupported(graphicsProfile);
2011-10-31 05:36:24 +00:00
}
public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
2015-10-24 19:26:27 +02:00
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
out int selectedMultiSampleCount)
2011-10-31 05:36:24 +00:00
{
2015-10-24 19:26:27 +02:00
return nativeAdapter.QueryBackBufferFormat(graphicsProfile, format, depthFormat, multiSampleCount, out selectedFormat, out selectedDepthFormat, out selectedMultiSampleCount);
2011-10-31 05:36:24 +00:00
}
public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat,
2015-10-24 19:26:27 +02:00
int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat,
out int selectedMultiSampleCount)
2011-10-31 05:36:24 +00:00
{
2015-10-24 19:26:27 +02:00
return nativeAdapter.QueryRenderTargetFormat(graphicsProfile, format, depthFormat, multiSampleCount, out selectedFormat, out selectedDepthFormat, out selectedMultiSampleCount);
2011-10-31 05:36:24 +00:00
}
}
}