Browse Source

Add function to get the position of a monitor (and fix some comments) (#1449)

pull/1458/head
Jeffery Myers 4 years ago
committed by GitHub
parent
commit
03df593263
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 8 deletions
  1. +22
    -3
      src/core.c
  2. +6
    -5
      src/raylib.h

+ 22
- 3
src/core.c View File

@ -1437,7 +1437,26 @@ int GetMonitorCount(void)
#endif
}
// Get primary monitor width
// Get selected monitor width
Vector2 GetMonitorPosition(int monitor)
{
#if defined(PLATFORM_DESKTOP)
int monitorCount;
GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
if ((monitor >= 0) && (monitor < monitorCount))
{
int x, y;
glfwGetMonitorPos(monitors[monitor], &x, &y);
const GLFWvidmode* mode = glfwGetVideoMode(monitors[monitor]);
return (Vector2){ (float)x, (float)y };
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
#endif
return (Vector2){ 0, 0 };
}
// Get selected monitor width
int GetMonitorWidth(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@ -1454,7 +1473,7 @@ int GetMonitorWidth(int monitor)
return 0;
}
// Get primary monitor width
// Get selected monitor width
int GetMonitorHeight(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@ -1471,7 +1490,7 @@ int GetMonitorHeight(int monitor)
return 0;
}
// Get primary montior physical width in millimetres
// Get selected monitor physical width in millimetres
int GetMonitorPhysicalWidth(int monitor)
{
#if defined(PLATFORM_DESKTOP)

+ 6
- 5
src/raylib.h View File

@ -913,11 +913,12 @@ RLAPI void *GetWindowHandle(void); // Get native
RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height
RLAPI int GetMonitorCount(void); // Get number of connected monitors
RLAPI int GetMonitorWidth(int monitor); // Get primary monitor width
RLAPI int GetMonitorHeight(int monitor); // Get primary monitor height
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
RLAPI int GetMonitorPhysicalHeight(int monitor); // Get primary monitor physical height in millimetres
RLAPI int GetMonitorRefreshRate(int monitor); // Get primary monitor refresh rate
RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position
RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width
RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres
RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres
RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate
RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor
RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor

Loading…
Cancel
Save