gpt4 book ai didi

c++ - DXGI 显示器枚举未提供 Dell P2715Q 显示器的完整尺寸

转载 作者:可可西里 更新时间:2023-11-01 10:02:55 25 4
gpt4 key购买 nike

我制作 DXGI 适配器和监视器枚举。连接到我的计算机的第二台显示器是 Dell P2715Q,分辨率为 3840*2160:

Resolution

但是,程序将其报告为 2560*1440,这是第二个可用分辨率。重现的最少代码:

int main()
{
IDXGIFactory1* pFactory1;

HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory1));

if (FAILED(hr))
{
wcout << L"CreateDXGIFactory1 failed. " << endl;
return 0;
}

for (UINT i = 0;; i++)
{
IDXGIAdapter1* pAdapter1 = nullptr;

hr = pFactory1->EnumAdapters1(i, &pAdapter1);

if (hr == DXGI_ERROR_NOT_FOUND)
{
// no more adapters
break;
}

if (FAILED(hr))
{
wcout << L"EnumAdapters1 failed. " << endl;
return 0;
}

DXGI_ADAPTER_DESC1 desc;

hr = pAdapter1->GetDesc1(&desc);

if (FAILED(hr))
{
wcout << L"GetDesc1 failed. " << endl;
return 0;
}

wcout << L"Adapter: " << desc.Description << endl;

for (UINT j = 0;; j++)
{
IDXGIOutput *pOutput = nullptr;

HRESULT hr = pAdapter1->EnumOutputs(j, &pOutput);

if (hr == DXGI_ERROR_NOT_FOUND)
{
// no more outputs
break;
}

if (FAILED(hr))
{
wcout << L"EnumOutputs failed. " << endl;
return 0;
}

DXGI_OUTPUT_DESC desc;

hr = pOutput->GetDesc(&desc);

if (FAILED(hr))
{
wcout << L"GetDesc1 failed. " << endl;
return 0;
}

wcout << L" Output: " << desc.DeviceName <<
L" (" << desc.DesktopCoordinates.left << L"," << desc.DesktopCoordinates.top << L")-(" <<
(desc.DesktopCoordinates.right - desc.DesktopCoordinates.left) << L"," <<
(desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top) << L")" << endl;

}
}

return 0;
}

输出:

Adapter: Intel(R) Iris(TM) Pro Graphics 6200   Output: \\.\DISPLAY1  (0,0)-(1920,1200)   Output: \\.\DISPLAY2  (1920,0)-(2560,1440)

什么会导致此行为:DirectX 限制、视频内存、显示适配器、驱动程序、显示器?

环境:

Windows 10 x64Intel(R) Iris(TM) Pro Graphics 6200DELL P2715Q

最佳答案

您的应用程序被视为不了解 DPI 缩放。操作系统为您缩放坐标,大概是为了保持与遗留应用程序的兼容性。

让系统知道你知道High DPI Desktop Application Development你会得到你期望的坐标:

#include <ShellScalingAPI.h>

#pragma comment(lib, "shcore.lib")

int main()
{
SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE);
// there goes your code
Adapter: Intel(R) HD Graphics 4600
Output: \\.\DISPLAY4 (0,0)-(3840,2160)
Output: \\.\DISPLAY5 (3840,0)-(3840,2160)

没有SetProcessDpiAwareness:

Adapter: Intel(R) HD Graphics 4600
Output: \\.\DISPLAY4 (0,0)-(2194,1234)
Output: \\.\DISPLAY5 (2194,0)-(2194,1234)

备注DXGI_OUTPUT_DESC structure MSDN 评论:

DesktopCoordinates

Type: RECT

A RECT structure containing the bounds of the output in desktop coordinates. Desktop coordinates depend on the dots per inch (DPI) of the desktop. For info about writing DPI-aware Win32 apps, see High DPI.

关于c++ - DXGI 显示器枚举未提供 Dell P2715Q 显示器的完整尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48172751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com