mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Replaced glfwGetMonitorParam with glfwGetMonitor*.
Having one way to retrieve the cursor position and another (more verbose) way to retrieve the monitor position is inconsistent. Having them both work the same way is the least surprising thing. The expected glfwGetMonitorSize function gets an added Physical in its name so users won't confuse it with glfwGetVideoMode.
This commit is contained in:
parent
cb02a693b4
commit
ee5f30ea8f
@ -226,8 +226,8 @@ GLFW.
|
|||||||
handle
|
handle
|
||||||
* Added `glfwGetMonitors` and `glfwGetPrimaryMonitor` for enumerating available
|
* Added `glfwGetMonitors` and `glfwGetPrimaryMonitor` for enumerating available
|
||||||
monitors
|
monitors
|
||||||
* Added `glfwGetMonitorParam` and `glfwGetMonitorName` for retrieving monitor
|
* Added `glfwGetMonitorPos`, `glfwGetMonitorPhysicalSize` and
|
||||||
properties
|
`glfwGetMonitorName` for retrieving monitor properties
|
||||||
* Added `glfwSetMonitorCallback` and `GLFWmonitorfun` for notification of
|
* Added `glfwSetMonitorCallback` and `GLFWmonitorfun` for notification of
|
||||||
changes in the set of available monitors
|
changes in the set of available monitors
|
||||||
* Added `GLFWwindow` and updated window-related functions and callbacks to take
|
* Added `GLFWwindow` and updated window-related functions and callbacks to take
|
||||||
|
@ -539,11 +539,6 @@ extern "C" {
|
|||||||
|
|
||||||
#define GLFW_GAMMA_RAMP_SIZE 256
|
#define GLFW_GAMMA_RAMP_SIZE 256
|
||||||
|
|
||||||
#define GLFW_MONITOR_WIDTH_MM 0x00060001
|
|
||||||
#define GLFW_MONITOR_HEIGHT_MM 0x00060002
|
|
||||||
/* reuse GLFW_POSITION_X */
|
|
||||||
/* reuse GLFW_POSITION_Y */
|
|
||||||
|
|
||||||
#define GLFW_CONNECTED 0x00061000
|
#define GLFW_CONNECTED 0x00061000
|
||||||
#define GLFW_DISCONNECTED 0x00061001
|
#define GLFW_DISCONNECTED 0x00061001
|
||||||
|
|
||||||
@ -841,23 +836,21 @@ GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
|
GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
|
||||||
|
|
||||||
/*! @brief Returns a property of the specified monitor.
|
/*! @brief Returns the position of the monitor's viewport on the virtual screen.
|
||||||
* @param[in] monitor The monitor to query.
|
* @param[in] monitor The monitor to query.
|
||||||
* @param[in] param The property whose value to return.
|
* @param[out] xpos The monitor x-coordinate.
|
||||||
* @return The value of the property, or zero if an error occurred.
|
* @param[out] ypos The monitor y-coordinate.
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*
|
|
||||||
* @par Monitor properties
|
|
||||||
*
|
|
||||||
* The @ref GLFW_MONITOR_WIDTH_MM and @ref GLFW_MONITOR_HEIGHT_MM properties
|
|
||||||
* indicate the physical with, in mm, of the monitor.
|
|
||||||
*
|
|
||||||
* The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y properties indiciate the
|
|
||||||
* position, in virtual screen coordinates, of the monitor's viewport.
|
|
||||||
*
|
|
||||||
* @sa glfwGetVideoMode, glfwGetVideoModes, glfwGetMonitorName
|
|
||||||
*/
|
*/
|
||||||
GLFWAPI int glfwGetMonitorParam(GLFWmonitor* monitor, int param);
|
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
|
|
||||||
|
/*! @brief Returns the physical size of the monitor.
|
||||||
|
* @param[in] monitor The monitor to query.
|
||||||
|
* @param[out] width The width, in mm, of the monitor's display
|
||||||
|
* @param[out] height The height, in mm, of the monitor's display.
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
|
||||||
|
|
||||||
/*! @brief Returns the name of the specified monitor.
|
/*! @brief Returns the name of the specified monitor.
|
||||||
* @param[in] monitor The monitor to query.
|
* @param[in] monitor The monitor to query.
|
||||||
|
@ -312,31 +312,36 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
|
|||||||
return (GLFWmonitor*) primary;
|
return (GLFWmonitor*) primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwGetMonitorParam(GLFWmonitor* handle, int param)
|
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
|
||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
|
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (param)
|
if (xpos)
|
||||||
|
*xpos = monitor->positionX;
|
||||||
|
if (ypos)
|
||||||
|
*ypos = monitor->positionY;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* width, int* height)
|
||||||
|
{
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
|
||||||
|
if (!_glfwInitialized)
|
||||||
{
|
{
|
||||||
case GLFW_MONITOR_WIDTH_MM:
|
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
return monitor->widthMM;
|
return;
|
||||||
case GLFW_MONITOR_HEIGHT_MM:
|
|
||||||
return monitor->heightMM;
|
|
||||||
case GLFW_POSITION_X:
|
|
||||||
return monitor->positionX;
|
|
||||||
case GLFW_POSITION_Y:
|
|
||||||
return monitor->positionY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
if (width)
|
||||||
"glfwGetMonitorParam: Invalid enum value for 'param' parameter");
|
*width = monitor->widthMM;
|
||||||
return 0;
|
if (height)
|
||||||
|
*height = monitor->heightMM;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
||||||
|
@ -344,17 +344,19 @@ void monitor_callback(GLFWmonitor* monitor, int event)
|
|||||||
{
|
{
|
||||||
if (event == GLFW_CONNECTED)
|
if (event == GLFW_CONNECTED)
|
||||||
{
|
{
|
||||||
|
int x, y, widthMM, heightMM;
|
||||||
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
||||||
|
|
||||||
|
glfwGetMonitorPos(monitor, &x, &y);
|
||||||
|
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
|
||||||
|
|
||||||
printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n",
|
printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n",
|
||||||
counter++,
|
counter++,
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
glfwGetMonitorName(monitor),
|
glfwGetMonitorName(monitor),
|
||||||
mode.width, mode.height,
|
mode.width, mode.height,
|
||||||
glfwGetMonitorParam(monitor, GLFW_POSITION_X),
|
x, y,
|
||||||
glfwGetMonitorParam(monitor, GLFW_POSITION_Y),
|
widthMM, heightMM);
|
||||||
glfwGetMonitorParam(monitor, GLFW_MONITOR_WIDTH_MM),
|
|
||||||
glfwGetMonitorParam(monitor, GLFW_MONITOR_HEIGHT_MM));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -92,20 +92,19 @@ static void key_callback(GLFWwindow* window, int key, int action)
|
|||||||
|
|
||||||
static void list_modes(GLFWmonitor* monitor)
|
static void list_modes(GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
int count, widthMM, heightMM, dpi, i;
|
int count, x, y, widthMM, heightMM, dpi, i;
|
||||||
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
||||||
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
|
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
|
||||||
|
|
||||||
|
glfwGetMonitorPos(monitor, &x, &y);
|
||||||
|
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
|
||||||
|
|
||||||
printf("Name: %s (%s)\n",
|
printf("Name: %s (%s)\n",
|
||||||
glfwGetMonitorName(monitor),
|
glfwGetMonitorName(monitor),
|
||||||
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
||||||
printf("Current mode: %s\n", format_mode(&mode));
|
printf("Current mode: %s\n", format_mode(&mode));
|
||||||
printf("Virtual position: %i %i\n",
|
printf("Virtual position: %i %i\n", x, y);
|
||||||
glfwGetMonitorParam(monitor, GLFW_POSITION_X),
|
|
||||||
glfwGetMonitorParam(monitor, GLFW_POSITION_Y));
|
|
||||||
|
|
||||||
widthMM = glfwGetMonitorParam(monitor, GLFW_MONITOR_WIDTH_MM);
|
|
||||||
heightMM = glfwGetMonitorParam(monitor, GLFW_MONITOR_HEIGHT_MM);
|
|
||||||
dpi = (int) ((float) mode.width * 25.4f / (float) widthMM);
|
dpi = (int) ((float) mode.width * 25.4f / (float) widthMM);
|
||||||
printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi);
|
printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user