aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChrisDill <chrisdude134@gmail.com>2018-09-30 15:20:02 +0100
committerChrisDill <chrisdude134@gmail.com>2018-09-30 15:20:02 +0100
commit67dc50ef0077b194fa51014880e531b126d0b059 (patch)
tree6e33ae383afb2c0166dd404904a9a553959c13d6 /src
parent6b84b76b70be35b471ef31afc0f0dc4e16cfe383 (diff)
downloadraylib-67dc50ef0077b194fa51014880e531b126d0b059.tar.gz
raylib-67dc50ef0077b194fa51014880e531b126d0b059.zip
Changed monitor functions to use a index
- Using same idea as SetWindowMonitor to take in a index with 0 being the primary monitor.
Diffstat (limited to 'src')
-rw-r--r--src/core.c93
-rw-r--r--src/raylib.h10
2 files changed, 64 insertions, 39 deletions
diff --git a/src/core.c b/src/core.c
index e370d5e3..203da4d9 100644
--- a/src/core.c
+++ b/src/core.c
@@ -783,64 +783,89 @@ int GetMonitorCount(void)
}
// Get primary monitor width
-int GetMonitorWidth(void)
+int GetMonitorWidth(int monitor)
{
#if defined(PLATFORM_DESKTOP)
- GLFWmonitor *monitor = glfwGetPrimaryMonitor();
- const GLFWvidmode * mode = glfwGetVideoMode(monitor);
- return mode->width;
-#else
- return GetScreenWidth();
+ int monitorCount;
+ GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
+
+ if ((monitor >= 0) && (monitor < monitorCount))
+ {
+ const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
+ return mode->width;
+ }
+ else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
+ return 0;
}
-// Get primary monitor height
-int GetMonitorHeight(void)
-{
+// Get primary monitor width
+int GetMonitorHeight(int monitor)
+{
#if defined(PLATFORM_DESKTOP)
- GLFWmonitor *monitor = glfwGetPrimaryMonitor();
- const GLFWvidmode * mode = glfwGetVideoMode(monitor);
- return mode->height;
-#else
- return GetScreenHeight();
+ int monitorCount;
+ GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
+
+ if ((monitor >= 0) && (monitor < monitorCount))
+ {
+ const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
+ return mode->height;
+ }
+ else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
+ return 0;
}
// Get primary montior physical width in millimetres
-int GetMonitorPhysicalWidth(void)
+int GetMonitorPhysicalWidth(int monitor)
{
#if defined(PLATFORM_DESKTOP)
- int physicalWidth;
- GLFWmonitor *monitor = glfwGetPrimaryMonitor();
- glfwGetMonitorPhysicalSize(monitor, &physicalWidth, NULL);
- return physicalWidth;
-#else
- return 0;
+ int monitorCount;
+ GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
+
+ if ((monitor >= 0) && (monitor < monitorCount))
+ {
+ int physicalWidth;
+ glfwGetMonitorPhysicalSize(monitors[monitor], &physicalWidth, NULL);
+ return physicalWidth;
+ }
+ else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
+ return 0;
}
// Get primary monitor physical height in millimetres
-int GetMonitorPhysicalHeight(void)
+int GetMonitorPhysicalHeight(int monitor)
{
-#if defined(PLATFORM_DESKTOP)
- int physicalHeight;
- GLFWmonitor *monitor = glfwGetPrimaryMonitor();
- glfwGetMonitorPhysicalSize(monitor, NULL, &physicalHeight);
- return physicalHeight;
-#else
- return 0;
+#if defined(PLATFORM_DESKTOP)
+ int monitorCount;
+ GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
+
+ if ((monitor >= 0) && (monitor < monitorCount))
+ {
+ int physicalHeight;
+ glfwGetMonitorPhysicalSize(monitors[monitor], NULL, &physicalHeight);
+ return physicalHeight;
+ }
+ else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
+ return 0;
}
// Get the human-readable, UTF-8 encoded name of the primary monitor
-const char *GetMonitorName(void)
+const char *GetMonitorName(int monitor)
{
#if defined(PLATFORM_DESKTOP)
- GLFWmonitor *monitor = glfwGetPrimaryMonitor();
- return glfwGetMonitorName(monitor);
-#else
- return "";
+ int monitorCount;
+ GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
+
+ if ((monitor >= 0) && (monitor < monitorCount))
+ {
+ return glfwGetMonitorName(monitors[monitor]);
+ }
+ else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif
+ return "";
}
// Show mouse cursor
diff --git a/src/raylib.h b/src/raylib.h
index fb4fb842..17c4234e 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -815,11 +815,11 @@ RLAPI void SetWindowSize(int width, int height); // Set window
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(void); // Get primary monitor width
-RLAPI int GetMonitorHeight(void); // Get primary monitor height
-RLAPI int GetMonitorPhysicalWidth(void); // Get primary monitor physical width in millimetres
-RLAPI int GetMonitorPhysicalHeight(void); // Get primary monitor physical height in millimetres
-RLAPI const char *GetMonitorName(void); // Get the human-readable, UTF-8 encoded name of the primary monitor
+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 const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
// Cursor-related functions
RLAPI void ShowCursor(void); // Shows cursor