1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-10-08 15:17:25 -04:00

Fixed monitor enumeration on Win32.

This commit is contained in:
Camilla Berglund 2012-09-12 22:51:55 +02:00
parent f6ba959b1b
commit 4f8f6c7d89

View File

@ -202,8 +202,10 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
{ {
// Enumerate display adapters // Enumerate display adapters
DISPLAY_DEVICE adapter; DISPLAY_DEVICE adapter, monitor;
DWORD monitorIndex = 0; DEVMODE settings;
const char* name;
HDC dc;
ZeroMemory(&adapter, sizeof(DISPLAY_DEVICE)); ZeroMemory(&adapter, sizeof(DISPLAY_DEVICE));
adapter.cb = sizeof(DISPLAY_DEVICE); adapter.cb = sizeof(DISPLAY_DEVICE);
@ -219,23 +221,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
continue; 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)); ZeroMemory(&settings, sizeof(DEVMODE));
settings.dmSize = sizeof(DEVMODE); settings.dmSize = sizeof(DEVMODE);
@ -244,20 +229,13 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
&settings, &settings,
EDS_ROTATEDMODE); EDS_ROTATEDMODE);
name = _glfwCreateUTF8FromWideString(monitor.DeviceName); name = _glfwCreateUTF8FromWideString(adapter.DeviceName);
if (!name) if (!name)
{ {
// TODO: wat // TODO: wat
return NULL; return NULL;
} }
dc = CreateDC(L"DISPLAY", monitor.DeviceString, NULL, NULL);
if (!dc)
{
// TODO: wat
return NULL;
}
if (found == size) if (found == size)
{ {
if (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, monitors[found] = _glfwCreateMonitor(name,
GetDeviceCaps(dc, HORZSIZE), GetDeviceCaps(dc, HORZSIZE),
GetDeviceCaps(dc, VERTSIZE), GetDeviceCaps(dc, VERTSIZE),
@ -287,10 +277,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
return NULL; return NULL;
} }
monitors[found]->Win32.name = wcsdup(monitor.DeviceName); monitors[found]->Win32.name = wcsdup(adapter.DeviceName);
found++; found++;
} }
}
*count = found; *count = found;
return monitors; return monitors;