瀏覽代碼

Reviewed Windows building

pull/3328/head
Ray 1 年之前
父節點
當前提交
1ded340cf1
共有 2 個文件被更改,包括 16 次插入10 次删除
  1. +2
    -3
      src/rcore.c
  2. +14
    -7
      src/rcore_desktop.c

+ 2
- 3
src/rcore.c 查看文件

@ -297,10 +297,9 @@ static bool eventsRecording = false; // Record events
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
static void LoadFontDefault(void); // [Module: text] Loads default font on InitWindow()
static void UnloadFontDefault(void); // [Module: text] Unloads default font from GPU memory
extern void LoadFontDefault(void); // [Module: text] Loads default font on InitWindow()
extern void UnloadFontDefault(void); // [Module: text] Unloads default font from GPU memory
#endif #endif
static void InitTimer(void); // Initialize timer (hi-resolution if available) static void InitTimer(void); // Initialize timer (hi-resolution if available)

+ 14
- 7
src/rcore_desktop.c 查看文件

@ -1,12 +1,12 @@
#include <stdlib.h>
#include "rcore.h"
#include "raylib.h"
#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 #define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
// NOTE: Already provided by rlgl implementation (on glad.h) // NOTE: Already provided by rlgl implementation (on glad.h)
#include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management #include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management
// NOTE: GLFW3 already includes gl.h (OpenGL) headers // NOTE: GLFW3 already includes gl.h (OpenGL) headers
extern CoreData CORE; // Global CORE state context
// Support retrieving native window handlers // Support retrieving native window handlers
#if defined(_WIN32) #if defined(_WIN32)
typedef void *PVOID; typedef void *PVOID;
@ -1173,19 +1173,22 @@ void *GetWindowHandle(void)
// Get number of monitors // Get number of monitors
int GetMonitorCount(void) int GetMonitorCount(void)
{ {
int monitorCount;
int monitorCount = 0;
glfwGetMonitors(&monitorCount); glfwGetMonitors(&monitorCount);
return monitorCount; return monitorCount;
} }
// Get number of monitors // Get number of monitors
int GetCurrentMonitor(void) int GetCurrentMonitor(void)
{ {
int index = 0; int index = 0;
int monitorCount;
int monitorCount = 0;
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount); GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
GLFWmonitor *monitor = NULL; GLFWmonitor *monitor = NULL;
if (monitorCount > 1)
if (monitorCount >= 1)
{ {
if (IsWindowFullscreen()) if (IsWindowFullscreen())
{ {
@ -1216,6 +1219,7 @@ int GetCurrentMonitor(void)
monitor = monitors[i]; monitor = monitors[i];
glfwGetMonitorPos(monitor, &mx, &my); glfwGetMonitorPos(monitor, &mx, &my);
const GLFWvidmode *mode = glfwGetVideoMode(monitor); const GLFWvidmode *mode = glfwGetVideoMode(monitor);
if (mode) if (mode)
{ {
const int width = mode->width; const int width = mode->width;
@ -1234,6 +1238,8 @@ int GetCurrentMonitor(void)
} }
} }
} }
return index;
} }
// Get selected monitor position // Get selected monitor position
@ -1256,7 +1262,7 @@ Vector2 GetMonitorPosition(int monitor)
// Get selected monitor width (currently used by monitor) // Get selected monitor width (currently used by monitor)
int GetMonitorWidth(int monitor) int GetMonitorWidth(int monitor)
{ {
int monitorCount;
int monitorCount = 0;
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount); GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
if ((monitor >= 0) && (monitor < monitorCount)) if ((monitor >= 0) && (monitor < monitorCount))
@ -1267,6 +1273,7 @@ int GetMonitorWidth(int monitor)
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor"); else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
} }
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor"); else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
return 0; return 0;
} }

Loading…
取消
儲存