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:
Родитель
cb02a693b4
Коммит
ee5f30ea8f
|
@ -226,8 +226,8 @@ GLFW.
|
|||
handle
|
||||
* Added `glfwGetMonitors` and `glfwGetPrimaryMonitor` for enumerating available
|
||||
monitors
|
||||
* Added `glfwGetMonitorParam` and `glfwGetMonitorName` for retrieving monitor
|
||||
properties
|
||||
* Added `glfwGetMonitorPos`, `glfwGetMonitorPhysicalSize` and
|
||||
`glfwGetMonitorName` for retrieving monitor properties
|
||||
* Added `glfwSetMonitorCallback` and `GLFWmonitorfun` for notification of
|
||||
changes in the set of available monitors
|
||||
* 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_MONITOR_WIDTH_MM 0x00060001
|
||||
#define GLFW_MONITOR_HEIGHT_MM 0x00060002
|
||||
/* reuse GLFW_POSITION_X */
|
||||
/* reuse GLFW_POSITION_Y */
|
||||
|
||||
#define GLFW_CONNECTED 0x00061000
|
||||
#define GLFW_DISCONNECTED 0x00061001
|
||||
|
||||
|
@ -841,23 +836,21 @@ GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
|
|||
*/
|
||||
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] param The property whose value to return.
|
||||
* @return The value of the property, or zero if an error occurred.
|
||||
* @param[out] xpos The monitor x-coordinate.
|
||||
* @param[out] ypos The monitor y-coordinate.
|
||||
* @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.
|
||||
* @param[in] monitor The monitor to query.
|
||||
|
|
|
@ -312,31 +312,36 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
|
|||
return (GLFWmonitor*) primary;
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetMonitorParam(GLFWmonitor* handle, int param)
|
||||
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_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:
|
||||
return monitor->widthMM;
|
||||
case GLFW_MONITOR_HEIGHT_MM:
|
||||
return monitor->heightMM;
|
||||
case GLFW_POSITION_X:
|
||||
return monitor->positionX;
|
||||
case GLFW_POSITION_Y:
|
||||
return monitor->positionY;
|
||||
_glfwInputError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM,
|
||||
"glfwGetMonitorParam: Invalid enum value for 'param' parameter");
|
||||
return 0;
|
||||
if (width)
|
||||
*width = monitor->widthMM;
|
||||
if (height)
|
||||
*height = monitor->heightMM;
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
||||
|
|
|
@ -344,17 +344,19 @@ void monitor_callback(GLFWmonitor* monitor, int event)
|
|||
{
|
||||
if (event == GLFW_CONNECTED)
|
||||
{
|
||||
int x, y, widthMM, heightMM;
|
||||
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",
|
||||
counter++,
|
||||
glfwGetTime(),
|
||||
glfwGetMonitorName(monitor),
|
||||
mode.width, mode.height,
|
||||
glfwGetMonitorParam(monitor, GLFW_POSITION_X),
|
||||
glfwGetMonitorParam(monitor, GLFW_POSITION_Y),
|
||||
glfwGetMonitorParam(monitor, GLFW_MONITOR_WIDTH_MM),
|
||||
glfwGetMonitorParam(monitor, GLFW_MONITOR_HEIGHT_MM));
|
||||
x, y,
|
||||
widthMM, heightMM);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -92,20 +92,19 @@ static void key_callback(GLFWwindow* window, int key, int action)
|
|||
|
||||
static void list_modes(GLFWmonitor* monitor)
|
||||
{
|
||||
int count, widthMM, heightMM, dpi, i;
|
||||
int count, x, y, widthMM, heightMM, dpi, i;
|
||||
GLFWvidmode mode = glfwGetVideoMode(monitor);
|
||||
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
|
||||
|
||||
glfwGetMonitorPos(monitor, &x, &y);
|
||||
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
|
||||
|
||||
printf("Name: %s (%s)\n",
|
||||
glfwGetMonitorName(monitor),
|
||||
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
||||
printf("Current mode: %s\n", format_mode(&mode));
|
||||
printf("Virtual position: %i %i\n",
|
||||
glfwGetMonitorParam(monitor, GLFW_POSITION_X),
|
||||
glfwGetMonitorParam(monitor, GLFW_POSITION_Y));
|
||||
printf("Virtual position: %i %i\n", x, y);
|
||||
|
||||
widthMM = glfwGetMonitorParam(monitor, GLFW_MONITOR_WIDTH_MM);
|
||||
heightMM = glfwGetMonitorParam(monitor, GLFW_MONITOR_HEIGHT_MM);
|
||||
dpi = (int) ((float) mode.width * 25.4f / (float) widthMM);
|
||||
printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче