Merge pull request #650 from ChrisDill/master

Added monitor functions
This commit is contained in:
Ray 2018-09-30 16:43:09 +02:00 committed by GitHub
commit 47fab2f54d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 104 additions and 0 deletions

View File

@ -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()
{

View File

@ -814,6 +814,12 @@ RLAPI void SetWindowMinSize(int width, int height); // Set window
RLAPI void SetWindowSize(int width, int height); // Set window dimensions
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 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