Added glfwGet*Adapter to native API.

This commit is contained in:
Camilla Berglund 2014-10-28 15:35:03 +01:00
parent 6743761c2c
commit 49ec306a0a
5 changed files with 59 additions and 7 deletions

View File

@ -66,7 +66,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
- Added `glfwCreateCursor`, `glfwDestroyCursor` and `glfwSetCursor` for - Added `glfwCreateCursor`, `glfwDestroyCursor` and `glfwSetCursor` for
managing custom system cursors managing custom system cursors
- Added `GLFWimage` struct for passing 32-bit RGBA images - Added `GLFWimage` struct for passing 32-bit RGBA images
- Added native monitor handle access to native API - Added monitor and adapter identifier access to native API
- Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files - Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files
- Added `glfwPostEmptyEvent` for allowing secondary threads to cause - Added `glfwPostEmptyEvent` for allowing secondary threads to cause
`glfwWaitEvents` to return `glfwWaitEvents` to return

View File

@ -108,9 +108,9 @@ extern "C" {
*************************************************************************/ *************************************************************************/
#if defined(GLFW_EXPOSE_NATIVE_WIN32) #if defined(GLFW_EXPOSE_NATIVE_WIN32)
/*! @brief Returns the display device name of the specified monitor. /*! @brief Returns the adapter device name of the specified monitor.
* *
* @return The UTF-8 encoded display device name (`DISPLAY_DEVICE.DeviceName`) * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
* of the specified monitor, or `NULL` if an [error](@ref error_handling) * of the specified monitor, or `NULL` if an [error](@ref error_handling)
* occurred. * occurred.
* *
@ -122,6 +122,22 @@ extern "C" {
* *
* @ingroup native * @ingroup native
*/ */
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
/*! @brief Returns the display device name of the specified monitor.
*
* @return The UTF-8 encoded display device name (for example
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @par Thread Safety
* This function may be called from any thread. Access is not synchronized.
*
* @par History
* Added in GLFW 3.1.
*
* @ingroup native
*/
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
/*! @brief Returns the `HWND` of the specified window. /*! @brief Returns the `HWND` of the specified window.
@ -222,6 +238,21 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
*/ */
GLFWAPI Display* glfwGetX11Display(void); GLFWAPI Display* glfwGetX11Display(void);
/*! @brief Returns the `RRCrtc` of the specified monitor.
*
* @return The `RRCrtc` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @par Thread Safety
* This function may be called from any thread. Access is not synchronized.
*
* @par History
* Added in GLFW 3.1.
*
* @ingroup native
*/
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
/*! @brief Returns the `RROutput` of the specified monitor. /*! @brief Returns the `RROutput` of the specified monitor.
* *
* @return The `RROutput` of the specified monitor, or `None` if an * @return The `RROutput` of the specified monitor, or `None` if an

View File

@ -160,10 +160,16 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
wcscpy(monitors[found]->win32.adapterName, adapter.DeviceName); wcscpy(monitors[found]->win32.adapterName, adapter.DeviceName);
wcscpy(monitors[found]->win32.displayName, display.DeviceName); wcscpy(monitors[found]->win32.displayName, display.DeviceName);
WideCharToMultiByte(CP_UTF8, 0,
adapter.DeviceName, -1,
monitors[found]->win32.publicAdapterName,
sizeof(monitors[found]->win32.publicAdapterName),
NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, WideCharToMultiByte(CP_UTF8, 0,
display.DeviceName, -1, display.DeviceName, -1,
monitors[found]->win32.nativeName, monitors[found]->win32.publicDisplayName,
sizeof(monitors[found]->win32.nativeName), sizeof(monitors[found]->win32.publicDisplayName),
NULL, NULL); NULL, NULL);
if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE && if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE &&
@ -326,10 +332,17 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
////// GLFW native API ////// ////// GLFW native API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->win32.publicAdapterName;
}
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->win32.nativeName; return monitor->win32.publicDisplayName;
} }

View File

@ -205,7 +205,8 @@ typedef struct _GLFWmonitorWin32
// This size matches the static size of DISPLAY_DEVICE.DeviceName // This size matches the static size of DISPLAY_DEVICE.DeviceName
WCHAR adapterName[32]; WCHAR adapterName[32];
WCHAR displayName[32]; WCHAR displayName[32];
char nativeName[64]; char publicAdapterName[64];
char publicDisplayName[64];
GLboolean modeChanged; GLboolean modeChanged;
} _GLFWmonitorWin32; } _GLFWmonitorWin32;

View File

@ -465,6 +465,13 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
////// GLFW native API ////// ////// GLFW native API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None);
return monitor->x11.crtc;
}
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
{ {
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;