mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-05 01:16:28 +00:00
Merge pull request #4836 from JeffM2501/unscale_on_resize
[rcore] Correctly handle window size on resize in auto-scaled HIGHDPI environment
This commit is contained in:
@@ -1753,8 +1753,14 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
|||||||
|
|
||||||
if (IsWindowFullscreen()) return;
|
if (IsWindowFullscreen()) return;
|
||||||
|
|
||||||
// Set current screen size
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
width = (int)(width / GetWindowScaleDPI().x);
|
||||||
|
height = (int)(height / GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set current screen size
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
|
||||||
|
@@ -1033,8 +1033,19 @@ void PollInputEvents(void)
|
|||||||
case RGFW_windowResized:
|
case RGFW_windowResized:
|
||||||
{
|
{
|
||||||
SetupViewport(platform.window->r.w, platform.window->r.h);
|
SetupViewport(platform.window->r.w, platform.window->r.h);
|
||||||
|
|
||||||
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = (int)(platform.window->r.w / GetWindowScaleDPI().x);
|
||||||
|
CORE.Window.screen.height = (int)(platform.window->r.h / GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CORE.Window.screen.width = platform.window->r.w;
|
CORE.Window.screen.width = platform.window->r.w;
|
||||||
CORE.Window.screen.height = platform.window->r.h;
|
CORE.Window.screen.height = platform.window->r.h;
|
||||||
|
}
|
||||||
|
|
||||||
CORE.Window.currentFbo.width = platform.window->r.w;
|
CORE.Window.currentFbo.width = platform.window->r.w;
|
||||||
CORE.Window.currentFbo.height = platform.window->r.h;
|
CORE.Window.currentFbo.height = platform.window->r.h;
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
|
@@ -1451,8 +1451,17 @@ void PollInputEvents(void)
|
|||||||
const int width = event.window.data1;
|
const int width = event.window.data1;
|
||||||
const int height = event.window.data2;
|
const int height = event.window.data2;
|
||||||
SetupViewport(width, height);
|
SetupViewport(width, height);
|
||||||
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
|
{
|
||||||
|
CORE.Window.screen.width = (int)(width / GetWindowScaleDPI().x);
|
||||||
|
CORE.Window.screen.height = (int)(height / GetWindowScaleDPI().y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
}
|
||||||
CORE.Window.currentFbo.width = width;
|
CORE.Window.currentFbo.width = width;
|
||||||
CORE.Window.currentFbo.height = height;
|
CORE.Window.currentFbo.height = height;
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
|
Reference in New Issue
Block a user