Changed monitor functions to use a index

- Using same idea as SetWindowMonitor to take in a index with 0 being the primary monitor.
This commit is contained in:
ChrisDill 2018-09-30 15:20:02 +01:00
parent 6b84b76b70
commit 67dc50ef00
2 changed files with 64 additions and 39 deletions

View file

@ -783,64 +783,89 @@ int GetMonitorCount(void)
} }
// Get primary monitor width // Get primary monitor width
int GetMonitorWidth(void) int GetMonitorWidth(int monitor)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); int monitorCount;
const GLFWvidmode * mode = glfwGetVideoMode(monitor); GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
return mode->width;
#else if ((monitor >= 0) && (monitor < monitorCount))
return GetScreenWidth(); {
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
return mode->width;
}
else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0;
} }
// Get primary monitor height // Get primary monitor width
int GetMonitorHeight(void) int GetMonitorHeight(int monitor)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); int monitorCount;
const GLFWvidmode * mode = glfwGetVideoMode(monitor); GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
return mode->height;
#else if ((monitor >= 0) && (monitor < monitorCount))
return GetScreenHeight(); {
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
return mode->height;
}
else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0;
} }
// Get primary montior physical width in millimetres // Get primary montior physical width in millimetres
int GetMonitorPhysicalWidth(void) int GetMonitorPhysicalWidth(int monitor)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
int physicalWidth; int monitorCount;
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
glfwGetMonitorPhysicalSize(monitor, &physicalWidth, NULL);
return physicalWidth; if ((monitor >= 0) && (monitor < monitorCount))
#else {
return 0; int physicalWidth;
glfwGetMonitorPhysicalSize(monitors[monitor], &physicalWidth, NULL);
return physicalWidth;
}
else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0;
} }
// Get primary monitor physical height in millimetres // Get primary monitor physical height in millimetres
int GetMonitorPhysicalHeight(void) int GetMonitorPhysicalHeight(int monitor)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
int physicalHeight; int monitorCount;
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
glfwGetMonitorPhysicalSize(monitor, NULL, &physicalHeight);
return physicalHeight; if ((monitor >= 0) && (monitor < monitorCount))
#else {
return 0; int physicalHeight;
glfwGetMonitorPhysicalSize(monitors[monitor], NULL, &physicalHeight);
return physicalHeight;
}
else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif #endif
return 0;
} }
// Get the human-readable, UTF-8 encoded name of the primary monitor // 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) #if defined(PLATFORM_DESKTOP)
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); int monitorCount;
return glfwGetMonitorName(monitor); GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
#else
return ""; if ((monitor >= 0) && (monitor < monitorCount))
{
return glfwGetMonitorName(monitors[monitor]);
}
else TraceLog(LOG_WARNING, "Selected monitor not found");
#endif #endif
return "";
} }
// Show mouse cursor // Show mouse cursor

View file

@ -815,11 +815,11 @@ RLAPI void SetWindowSize(int width, int height); // Set window
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(void); // Get primary monitor width RLAPI int GetMonitorWidth(int monitor); // Get primary monitor width
RLAPI int GetMonitorHeight(void); // Get primary monitor height RLAPI int GetMonitorHeight(int monitor); // Get primary monitor height
RLAPI int GetMonitorPhysicalWidth(void); // Get primary monitor physical width in millimetres RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
RLAPI int GetMonitorPhysicalHeight(void); // Get primary monitor physical height in millimetres RLAPI int GetMonitorPhysicalHeight(int monitor); // 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 const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
// Cursor-related functions // Cursor-related functions
RLAPI void ShowCursor(void); // Shows cursor RLAPI void ShowCursor(void); // Shows cursor