mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 12:02:00 +00:00
Fixed monitor enumeration on Win32.
This commit is contained in:
parent
f6ba959b1b
commit
4f8f6c7d89
@ -202,8 +202,10 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
// Enumerate display adapters
|
||||
|
||||
DISPLAY_DEVICE adapter;
|
||||
DWORD monitorIndex = 0;
|
||||
DISPLAY_DEVICE adapter, monitor;
|
||||
DEVMODE settings;
|
||||
const char* name;
|
||||
HDC dc;
|
||||
|
||||
ZeroMemory(&adapter, sizeof(DISPLAY_DEVICE));
|
||||
adapter.cb = sizeof(DISPLAY_DEVICE);
|
||||
@ -219,23 +221,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
continue;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// Enumerate monitors for the display adapter
|
||||
|
||||
DISPLAY_DEVICE monitor;
|
||||
DEVMODE settings;
|
||||
const char* name;
|
||||
HDC dc;
|
||||
|
||||
ZeroMemory(&monitor, sizeof(DISPLAY_DEVICE));
|
||||
monitor.cb = sizeof(DISPLAY_DEVICE);
|
||||
|
||||
if (!EnumDisplayDevices(adapter.DeviceName, monitorIndex, &monitor, 0))
|
||||
break;
|
||||
|
||||
monitorIndex++;
|
||||
|
||||
ZeroMemory(&settings, sizeof(DEVMODE));
|
||||
settings.dmSize = sizeof(DEVMODE);
|
||||
|
||||
@ -244,20 +229,13 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
&settings,
|
||||
EDS_ROTATEDMODE);
|
||||
|
||||
name = _glfwCreateUTF8FromWideString(monitor.DeviceName);
|
||||
name = _glfwCreateUTF8FromWideString(adapter.DeviceName);
|
||||
if (!name)
|
||||
{
|
||||
// TODO: wat
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dc = CreateDC(L"DISPLAY", monitor.DeviceString, NULL, NULL);
|
||||
if (!dc)
|
||||
{
|
||||
// TODO: wat
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (found == size)
|
||||
{
|
||||
if (size)
|
||||
@ -273,6 +251,18 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
}
|
||||
}
|
||||
|
||||
ZeroMemory(&monitor, sizeof(DISPLAY_DEVICE));
|
||||
monitor.cb = sizeof(DISPLAY_DEVICE);
|
||||
|
||||
EnumDisplayDevices(adapter.DeviceName, 0, &monitor, 0);
|
||||
|
||||
dc = CreateDC(L"DISPLAY", monitor.DeviceString, NULL, NULL);
|
||||
if (!dc)
|
||||
{
|
||||
// TODO: wat
|
||||
return NULL;
|
||||
}
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(name,
|
||||
GetDeviceCaps(dc, HORZSIZE),
|
||||
GetDeviceCaps(dc, VERTSIZE),
|
||||
@ -287,10 +277,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
monitors[found]->Win32.name = wcsdup(monitor.DeviceName);
|
||||
monitors[found]->Win32.name = wcsdup(adapter.DeviceName);
|
||||
found++;
|
||||
}
|
||||
}
|
||||
|
||||
*count = found;
|
||||
return monitors;
|
||||
|
Loading…
Reference in New Issue
Block a user