我知道把NVIDIA面板3d调成自动可以成功,但我需要在代码里解决这个问题
[C++] 纯文本查看 复制代码 D3D_DRIVER_TYPE DriverTypes[] =
{
D3D_DRIVER_TYPE_HARDWARE,
D3D_DRIVER_TYPE_WARP,
D3D_DRIVER_TYPE_REFERENCE,
};
UINT NumDriverTypes = ARRAYSIZE(DriverTypes);
// Feature levels supported
D3D_FEATURE_LEVEL FeatureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_1
};
UINT NumFeatureLevels = ARRAYSIZE(FeatureLevels);
D3D_FEATURE_LEVEL FeatureLevel;
//
// Create D3D device
//
for (UINT DriverTypeIndex = 0; DriverTypeIndex QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast(&hDxgiDevice));
if (FAILED(hr))
{
printf("m_hDevice->QueryInterface %d\n", GetLastError());
return FALSE;
}
//
// Get DXGI adapter
//
IDXGIAdapter* hDxgiAdapter = NULL;
hr = hDxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast(&hDxgiAdapter));
RESET_OBJECT(hDxgiDevice);
if (FAILED(hr))
{
printf("hDxgiDevice->GetParent %d\n", GetLastError());
return FALSE;
}
//
// Get output
//
INT nOutput = 0;
IDXGIOutput* hDxgiOutput = NULL;
hr = hDxgiAdapter->EnumOutputs(nOutput, &hDxgiOutput);
RESET_OBJECT(hDxgiAdapter);
if (FAILED(hr))
{
printf("hDxgiAdapter->EnumOutputs %d\n", GetLastError());
return FALSE;
}
//
// get output description struct
//
hDxgiOutput->GetDesc(&m_dxgiOutDesc);
//
// QI for Output 1
//
IDXGIOutput1* hDxgiOutput1 = NULL;
hr = hDxgiOutput->QueryInterface(__uuidof(hDxgiOutput1), reinterpret_cast(&hDxgiOutput1));
RESET_OBJECT(hDxgiOutput);
if (FAILED(hr))
{
printf("hDxgiOutput->QueryInterface %d\n", GetLastError());
return FALSE;
}
//
// Create desktop duplication
//
hr = hDxgiOutput1->DuplicateOutput(m_hDevice, &m_hDeskDupl);
RESET_OBJECT(hDxgiOutput1);
if (FAILED(hr))
{
printf("hDxgiOutput1->DuplicateOutput %d\n", GetLastError());
return FALSE;
}