【发布时间】:2014-04-09 01:14:49
【问题描述】:
如何检测 Windows 7 机器上的 directx 版本是 11 还是 11.1?
最好通过 PInvoke 或 SharpDX 使用 .NET 语言?
【问题讨论】:
标签: .net windows-7 directx sharpdx
如何检测 Windows 7 机器上的 directx 版本是 11 还是 11.1?
最好通过 PInvoke 或 SharpDX 使用 .NET 语言?
【问题讨论】:
标签: .net windows-7 directx sharpdx
只需尝试创建具有特定功能级别(以及其他参数)的设备。
在本机代码中(使用D3D11CreateDevice* 函数之一)。如果功能不成功 - 不支持功能级别。为方便起见,我们通常传递功能级别数组,然后,如果设备不是nullptr,我们可以检查哪一个是最高支持的:
const D3D_FEATURE_LEVEL arrFeatLevels[] =
{
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1,
};
const unsigned int nFeatLevels = _countof(arrFeatLevels);
D3D11CreateDeviceAndSwapChain(..., arrFeatLevels, nFeatLevels, ...,
&m_Device, &featureLevel, &m_Context);
if (m_Device && m_Context)
{
featureLevel // you can access to highest supported feature level here
在 SharpDX 中,您需要使用构造函数,它接受特定的功能级别:
Device(DriverType, DeviceCreationFlags, FeatureLevel[])
如果设备创建成功,则检查Device.FeatureLevel 属性。
编码愉快!
编辑
我想我误解了你的问题。您询问了检测操作系统支持哪个版本,而不是操作系统+显卡+驱动程序一起检测。支持的最大版本预装了操作系统,因此您只需要知道您在哪个操作系统上:
OS version Version of DX runtime
Windows Vista DirectX 10
Windows Vista SP1/SP2 DirectX 10.1
Windows Vista SP2 DirectX 11.0
Windows 7 DirectX 11.0
Windows 7 SP1 DirectX 11.0
Windows 7 SP1 with KB2670838 DirectX 11.1
Windows 8 / Windows RT DirectX 11.1
Windows 8.1 / Windows RT DirectX 11.2
来源:
您还可以查询d3d11.dll 的版本并与维基页面上的版本进行比较。
见:
【讨论】: