From 99cedceef5867bdc377ce0406ddecad9a4ab292d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 12 Sep 2014 17:03:44 +0200 Subject: [PATCH] Expose display device name as UTF-8. This makes interaction with libOVR simpler, as it provides the display device name in the same encoding. --- include/GLFW/glfw3native.h | 2 +- src/win32_monitor.c | 10 ++++++++-- src/win32_platform.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 13c9f81e..1e176a12 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -112,7 +112,7 @@ extern "C" { * @return The the display device name of the specified monitor. * @ingroup native */ -GLFWAPI const WCHAR* glfwGetWin32Monitor(GLFWmonitor* monitor); +GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); /*! @brief Returns the `HWND` of the specified window. * @return The `HWND` of the specified window. diff --git a/src/win32_monitor.c b/src/win32_monitor.c index bc528b1f..ee44d5d3 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -160,6 +160,12 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count) wcscpy(monitors[found]->win32.adapterName, adapter.DeviceName); wcscpy(monitors[found]->win32.displayName, display.DeviceName); + WideCharToMultiByte(CP_UTF8, 0, + display.DeviceName, -1, + monitors[found]->win32.nativeName, + sizeof(monitors[found]->win32.nativeName), + NULL, NULL); + if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE && displayIndex == 0) { @@ -320,10 +326,10 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) ////// GLFW native API ////// ////////////////////////////////////////////////////////////////////////// -GLFWAPI const WCHAR* glfwGetWin32Monitor(GLFWmonitor* handle) +GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - return monitor->win32.displayName; + return monitor->win32.nativeName; } diff --git a/src/win32_platform.h b/src/win32_platform.h index 09dab722..465e487d 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -205,6 +205,7 @@ typedef struct _GLFWmonitorWin32 // This size matches the static size of DISPLAY_DEVICE.DeviceName WCHAR adapterName[32]; WCHAR displayName[32]; + char nativeName[64]; GLboolean modeChanged; } _GLFWmonitorWin32;