summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2018-09-30 16:43:09 +0200
committerGitHub <[email protected]>2018-09-30 16:43:09 +0200
commit47fab2f54d569554a185d820050a7a78826ae734 (patch)
tree6e33ae383afb2c0166dd404904a9a553959c13d6 /src/core.c
parent29eddb9ff3fda090ed416a2736a6d2db4cca77e9 (diff)
parent67dc50ef0077b194fa51014880e531b126d0b059 (diff)
downloadraylib-47fab2f54d569554a185d820050a7a78826ae734.tar.gz
raylib-47fab2f54d569554a185d820050a7a78826ae734.zip
Merge pull request #650 from ChrisDill/master
Added monitor functions
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index 5f155a0a..203da4d9 100644
--- a/src/core.c
+++ b/src/core.c
@@ -770,6 +770,104 @@ int GetScreenHeight(void)
return screenHeight;
}
+// Get number of monitors
+int GetMonitorCount(void)
+{
+#if defined(PLATFORM_DESKTOP)
+ int monitorCount;
+ glfwGetMonitors(&monitorCount);
+ return monitorCount;
+#else
+ return 1;
+#endif
+}
+
+// Get primary monitor width
+int GetMonitorWidth(int monitor)
+{
+#if defined(PLATFORM_DESKTOP)
+ 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 width
+int GetMonitorHeight(int monitor)
+{
+#if defined(PLATFORM_DESKTOP)
+ 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(int monitor)
+{
+#if defined(PLATFORM_DESKTOP)
+ 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(int monitor)
+{
+#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(int monitor)
+{
+#if defined(PLATFORM_DESKTOP)
+ 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
void ShowCursor()
{