Fix high DPI render size and window deformation
This commit is contained in:
parent
74f7112614
commit
a312a8ad42
|
|
@ -1808,30 +1808,35 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||||
// WARNING: On window minimization, callback is called,
|
// WARNING: On window minimization, callback is called,
|
||||||
// but we don't want to change internal screen values, it breaks things
|
// but we don't want to change internal screen values, it breaks things
|
||||||
if ((width == 0) || (height == 0)) return;
|
if ((width == 0) || (height == 0)) return;
|
||||||
|
int fbWidth, fbHeight;
|
||||||
|
glfwGetFramebufferSize(window, &fbWidth, &fbHeight);
|
||||||
|
|
||||||
// Reset viewport and projection matrix for new size
|
// Reset viewport and projection matrix for new size
|
||||||
SetupViewport(width, height);
|
SetupViewport(fbWidth, fbHeight);
|
||||||
|
|
||||||
CORE.Window.currentFbo.width = width;
|
CORE.Window.currentFbo.width = fbWidth;
|
||||||
CORE.Window.currentFbo.height = height;
|
CORE.Window.currentFbo.height = fbHeight;
|
||||||
CORE.Window.resizedLastFrame = true;
|
CORE.Window.resizedLastFrame = true;
|
||||||
|
|
||||||
if (IsWindowFullscreen()) return;
|
if (IsWindowFullscreen()) return;
|
||||||
|
int logicalWidth = width;
|
||||||
|
int logicalHeight = height;
|
||||||
|
|
||||||
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
||||||
{
|
{
|
||||||
width = (int)(width/GetWindowScaleDPI().x);
|
Vector2 dpiScale = GetWindowScaleDPI();
|
||||||
height = (int)(height/GetWindowScaleDPI().y);
|
logicalWidth = (int)(fbWidth / dpiScale.x);
|
||||||
|
logicalHeight = (int)(fbHeight / dpiScale.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set render size
|
// Set render size
|
||||||
CORE.Window.render.width = width;
|
CORE.Window.render.width = fbWidth;
|
||||||
CORE.Window.render.height = height;
|
CORE.Window.render.height = fbHeight;
|
||||||
|
|
||||||
// Set current screen size
|
// Set current screen size
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = logicalWidth;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = logicalHeight;
|
||||||
|
|
||||||
// WARNING: If using a render texture, it is not scaled to new size
|
// WARNING: If using a render texture, it is not scaled to new size
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user