From 068fc48fdad0fbc78b9c6da2805e231e4bb15618 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 27 Dec 2020 16:26:52 +0100 Subject: [PATCH 1/5] Update HISTORY.md --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 995423b3c..6291d5f29 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -270,7 +270,7 @@ First, some general numbers of this new update: Here the list with some highlights for `raylib 3.5`. - - NEW **Platform** supported: **Raspberry Pi 4 native mode** (no X11 windows) through [DRM](https://en.wikipedia.org/wiki/Direct_Rendering_Manager) subsystem and GBM API. Actually this is a really interesting improvement because it opens the door to raylib to support other embedded platforms (Odroid, GameShell, NanoPi...). Also worth mentioning the un-official homebrew ports of raylib for [PS4](https://github.com/orbisdev/orbisdev-orbisGl2) and PSVita. + - NEW **Platform** supported: **Raspberry Pi 4 native mode** (no X11 windows) through [DRM](https://en.wikipedia.org/wiki/Direct_Rendering_Manager) subsystem and GBM API. Actually this is a really interesting improvement because it opens the door to raylib to support other embedded platforms (Odroid, GameShell, NanoPi...). Also worth mentioning the un-official homebrew ports of raylib for [PS4](https://github.com/orbisdev/orbisdev-orbisGl2) and [PSVita](https://github.com/psp2dev/raylib4Vita). - NEW **configuration options** exposed: For custom raylib builds, `config.h` now exposes **more than 150 flags and defines** to build raylib with only the desired features, for example, it allows to build a minimal raylib library in just some KB removing all external data filetypes supported, very useful to generate **small executables or embedded devices**. From 227496bea7bd5e986ee39a888c25ec2169c491d5 Mon Sep 17 00:00:00 2001 From: Matheus Duarte Date: Mon, 28 Dec 2020 07:10:39 -0300 Subject: [PATCH 2/5] providing and example on how to apply the screen scale (as done in the virtual mouse) to the real mouse, to work with raygui (#1481) --- examples/core/core_window_letterbox.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/core/core_window_letterbox.c b/examples/core/core_window_letterbox.c index 4402dd2a3..f28f2a5f8 100644 --- a/examples/core/core_window_letterbox.c +++ b/examples/core/core_window_letterbox.c @@ -71,6 +71,11 @@ int main(void) virtualMouse.x = (mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale; virtualMouse.y = (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale; virtualMouse = ClampValue(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ gameScreenWidth, gameScreenHeight }); + + // Apply the same transformation as the virtual mouse to the real mouse, to work with raygui. + // SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth * scale)) * 0.5f, -(GetScreenHeight() - (gameScreenHeight * scale)) * 0.5f); + // SetMouseScale(1 / scale, 1 / scale); + //---------------------------------------------------------------------------------- // Draw From abdd57db0b6b8fdf4ed203e349b74a23f296d4f0 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 28 Dec 2020 11:19:05 +0100 Subject: [PATCH 3/5] Review comments formating --- examples/core/core_window_letterbox.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/core/core_window_letterbox.c b/examples/core/core_window_letterbox.c index f28f2a5f8..1712b9ba5 100644 --- a/examples/core/core_window_letterbox.c +++ b/examples/core/core_window_letterbox.c @@ -72,10 +72,9 @@ int main(void) virtualMouse.y = (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale; virtualMouse = ClampValue(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ gameScreenWidth, gameScreenHeight }); - // Apply the same transformation as the virtual mouse to the real mouse, to work with raygui. - // SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth * scale)) * 0.5f, -(GetScreenHeight() - (gameScreenHeight * scale)) * 0.5f); - // SetMouseScale(1 / scale, 1 / scale); - + // Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui) + //SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f); + //SetMouseScale(1/scale, 1/scale); //---------------------------------------------------------------------------------- // Draw From d3db690c422862ba785d9f05f44d5e5068088bde Mon Sep 17 00:00:00 2001 From: hristo Date: Tue, 29 Dec 2020 14:35:47 +0200 Subject: [PATCH 4/5] I noticed that toggle fullscreen always gets the primary monitor when its more intuitive to use the monitor that the window is currently in. (#1486) This monitor should even probably be passed as an id instead to make it more consistent with the rest of the API but this would break existing applications so I am hesitant to change the function signature directly. --- src/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index e6d27e5f9..6fc20eeb2 100644 --- a/src/core.c +++ b/src/core.c @@ -1025,7 +1025,7 @@ void ToggleFullscreen(void) // Store previous window position (in case we exit fullscreen) glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y); - GLFWmonitor *monitor = glfwGetPrimaryMonitor(); + GLFWmonitor *monitor = glfwGetWindowMonitor(CORE.Window.handle); if (!monitor) { TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor"); @@ -1034,7 +1034,7 @@ void ToggleFullscreen(void) } const GLFWvidmode *mode = glfwGetVideoMode(monitor); - glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate); + glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate); // 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 From 75c6fd047bed24146fc6dca0c4a51c8555bc02e3 Mon Sep 17 00:00:00 2001 From: hristo Date: Tue, 29 Dec 2020 14:37:08 +0200 Subject: [PATCH 5/5] Monitor utilites (#1485) * Added a new utility function to get the current monitor. Some of the other functions rely on passing on a monitor id but we only have a function for querying the count of monitors available. * Updated the comment to correctly reflect the function action --- src/core.c | 10 ++++++++++ src/raylib.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/core.c b/src/core.c index 6fc20eeb2..905367c9c 100644 --- a/src/core.c +++ b/src/core.c @@ -1452,6 +1452,16 @@ int GetMonitorCount(void) #endif } +// Get number of monitors +int GetCurrentMonitor(void) +{ +#if defined(PLATFORM_DESKTOP) + return glfwGetWindowMonitor(CORE.Window.handle); +#else + return 0; +#endif +} + // Get selected monitor width Vector2 GetMonitorPosition(int monitor) { diff --git a/src/raylib.h b/src/raylib.h index 031640b12..fd85814ba 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -916,6 +916,7 @@ RLAPI void *GetWindowHandle(void); // Get native 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 GetCurrentMonitor(void); // Get current connected monitor RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height