Add function to get the position of a monitor (and fix some comments) (#1449)
This commit is contained in:
parent
62406259d7
commit
03df593263
2 changed files with 28 additions and 8 deletions
25
src/core.c
25
src/core.c
|
@ -1437,7 +1437,26 @@ int GetMonitorCount(void)
|
||||||
#endif
|
#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)
|
int GetMonitorWidth(int monitor)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
@ -1454,7 +1473,7 @@ int GetMonitorWidth(int monitor)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get primary monitor width
|
// Get selected monitor width
|
||||||
int GetMonitorHeight(int monitor)
|
int GetMonitorHeight(int monitor)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
@ -1471,7 +1490,7 @@ int GetMonitorHeight(int monitor)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get primary montior physical width in millimetres
|
// Get selected monitor physical width in millimetres
|
||||||
int GetMonitorPhysicalWidth(int monitor)
|
int GetMonitorPhysicalWidth(int monitor)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
|
11
src/raylib.h
11
src/raylib.h
|
@ -913,11 +913,12 @@ RLAPI void *GetWindowHandle(void); // Get native
|
||||||
RLAPI int GetScreenWidth(void); // Get current screen width
|
RLAPI int GetScreenWidth(void); // Get current screen width
|
||||||
RLAPI int GetScreenHeight(void); // Get current screen height
|
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||||
RLAPI int GetMonitorCount(void); // Get number of connected monitors
|
RLAPI int GetMonitorCount(void); // Get number of connected monitors
|
||||||
RLAPI int GetMonitorWidth(int monitor); // Get primary monitor width
|
RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position
|
||||||
RLAPI int GetMonitorHeight(int monitor); // Get primary monitor height
|
RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width
|
||||||
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
|
RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height
|
||||||
RLAPI int GetMonitorPhysicalHeight(int monitor); // Get primary monitor physical height in millimetres
|
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres
|
||||||
RLAPI int GetMonitorRefreshRate(int monitor); // Get primary monitor refresh rate
|
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 GetWindowPosition(void); // Get window position XY on monitor
|
||||||
RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor
|
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
|
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue