From 19651cfaad679e89329d252511b2516ad5146b31 Mon Sep 17 00:00:00 2001 From: Kirottu <56396750+Kirottu@users.noreply.github.com> Date: Mon, 8 Mar 2021 23:12:27 +0200 Subject: [PATCH 1/2] Added SUPPORT_STANDARD_FILEIO flag support for the CMake build system (#1638) * Update CMakeOptions.txt * Update config.h.in * Added SUPPORT_STANDARD_FILEIO to CMakeOptions.txt * Fixed typo * Added SUPPORT_STANDARD_FILEIO to CompileDefinitions.cmake Co-authored-by: KirottuM --- CMakeOptions.txt | 1 + cmake/CompileDefinitions.cmake | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeOptions.txt b/CMakeOptions.txt index d60ca2b79..ebdba0c9b 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -86,4 +86,5 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" O cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF) # utils.c +cmake_dependent_option(SUPPORT_STANDARD_FILEIO "Support standard file io library (stdio.h)" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON CUSTOMIZE_BUILD ON) diff --git a/cmake/CompileDefinitions.cmake b/cmake/CompileDefinitions.cmake index b07503c16..36062b309 100644 --- a/cmake/CompileDefinitions.cmake +++ b/cmake/CompileDefinitions.cmake @@ -54,6 +54,7 @@ if (${CUSTOMIZE_BUILD}) define_if("raylib" SUPPORT_FILEFORMAT_MOD) define_if("raylib" SUPPORT_FILEFORMAT_FLAC) define_if("raylib" SUPPORT_FILEFORMAT_MP3) + define_if("raylib" SUPPORT_STANDARD_FILEIO) define_if("raylib" SUPPORT_TRACELOG) define_if("raylib" SUPPORT_COMPRESSION_API) From ef9f67749a51bcde62b3a46f692d5a0f1d2c1d1f Mon Sep 17 00:00:00 2001 From: Hristo Stamenov Date: Mon, 8 Mar 2021 23:51:10 +0200 Subject: [PATCH 2/2] Fix fullscreen resolution (#1637) * Always try to set vsync. Use the internal monitor function to correctly get the display for windows. * Modified how fullscreen gets toggled. - Removed the unsetting and setting of the resize callback function. Instead of that I moved the fullscreen flag setting into a more correct place before setting the fullscreen so that this flag can be used in the callback. - In the resize callback now window size is only set when it is not fullscreen resulting in preserving the window size. - When going fullscreen the larges resolution is used so that there are no problems of the type when you minimize the window you cannot use anything else in your desktop because the resolution might be too low. If a low res effect is desired one should use render texture (this is the approach all game engines use). * Set correct return to window in case of fail to get monitor. * Set the refresh rate on the mode. * Made changes based on review from @raysan5 Co-authored-by: Jeffery Myers --- src/core.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/core.c b/src/core.c index 75b38766d..c4b52b874 100644 --- a/src/core.c +++ b/src/core.c @@ -1044,31 +1044,31 @@ void ToggleFullscreen(void) if (!monitor) { TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor"); - glfwSetWindowSizeCallback(CORE.Window.handle, NULL); - glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); - glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); + + CORE.Window.fullscreen = false; // Toggle fullscreen flag + CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE; + + glfwSetWindowMonitor(CORE.Window.handle, NULL, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); return; } - const GLFWvidmode *mode = glfwGetVideoMode(monitor); - glfwSetWindowSizeCallback(CORE.Window.handle, NULL); + CORE.Window.fullscreen = true; // Toggle fullscreen flag + CORE.Window.flags |= FLAG_FULLSCREEN_MODE; + glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); - glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); } else { - glfwSetWindowSizeCallback(CORE.Window.handle, NULL); + CORE.Window.fullscreen = false; // Toggle fullscreen flag + CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE; + glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); - glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); } // Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS) // NOTE: V-Sync can be enabled by graphic driver configuration if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1); - CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag - CORE.Window.flags ^= FLAG_FULLSCREEN_MODE; - #endif #if defined(PLATFORM_WEB) /* @@ -4619,16 +4619,18 @@ static void ErrorCallback(int error, const char *description) static void WindowSizeCallback(GLFWwindow *window, int width, int height) { SetupViewport(width, height); // Reset viewport and projection matrix for new size - + CORE.Window.currentFbo.width = width; + CORE.Window.currentFbo.height = height; + CORE.Window.resizedLastFrame = true; + + if(IsWindowFullscreen()) + return; + // Set current screen size CORE.Window.screen.width = width; CORE.Window.screen.height = height; - CORE.Window.currentFbo.width = width; - CORE.Window.currentFbo.height = height; - // NOTE: Postprocessing texture is not scaled to new size - CORE.Window.resizedLastFrame = true; } // GLFW3 WindowIconify Callback, runs when window is minimized/restored