瀏覽代碼

GetMonitorWidth()/GetMonitorHeight(): return current video resolution instead max available (#2514)

* GetMonitorWidth()/GetMonitorHeight(): current video resolution instead max available

* adapt header comment to reflect change
pull/2517/head
gulrak 3 年之前
committed by GitHub
父節點
當前提交
5e3ef42201
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 2 個檔案被更改,包括 9 行新增15 行删除
  1. +2
    -2
      src/raylib.h
  2. +7
    -13
      src/rcore.c

+ 2
- 2
src/raylib.h 查看文件

@ -939,8 +939,8 @@ RLAPI int GetRenderHeight(void); // Get current
RLAPI int GetMonitorCount(void); // Get number of connected monitors
RLAPI int GetCurrentMonitor(void); // Get current connected monitor
RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position
RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (max available by monitor)
RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (max available by monitor)
RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor)
RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor)
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres
RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres
RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate

+ 7
- 13
src/rcore.c 查看文件

@ -1723,7 +1723,7 @@ int GetCurrentMonitor(void)
#endif
}
// Get selected monitor width
// Get selected monitor position
Vector2 GetMonitorPosition(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@ -1742,7 +1742,7 @@ Vector2 GetMonitorPosition(int monitor)
return (Vector2){ 0, 0 };
}
// Get selected monitor width (max available by monitor)
// Get selected monitor width (currently used by monitor)
int GetMonitorWidth(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@ -1751,11 +1751,8 @@ int GetMonitorWidth(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
int count = 0;
const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
// We return the maximum resolution available, the last one in the modes array
if (count > 0) return modes[count - 1].width;
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
if(mode) return mode->width;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
@ -1763,7 +1760,7 @@ int GetMonitorWidth(int monitor)
return 0;
}
// Get selected monitor width (max available by monitor)
// Get selected monitor height (currently used by monitor)
int GetMonitorHeight(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@ -1772,11 +1769,8 @@ int GetMonitorHeight(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
int count = 0;
const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
// We return the maximum resolution available, the last one in the modes array
if (count > 0) return modes[count - 1].height;
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
if(mode) return mode->height;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");

Loading…
取消
儲存