summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Heber <[email protected]>2021-03-20 13:57:29 -0500
committerGitHub <[email protected]>2021-03-20 19:57:29 +0100
commitf4d6bad607ef1eb1f932abdc9b357802925a012f (patch)
treee7783f2cf54f73fdb9427accbd0aeeb0840ddfe9
parenta76fcaba3ea8092be4b5ee26f6e97948b20129aa (diff)
downloadraylib-f4d6bad607ef1eb1f932abdc9b357802925a012f.tar.gz
raylib-f4d6bad607ef1eb1f932abdc9b357802925a012f.zip
Considering the window's scale when setting the viewport. (#1659)
This appears to fix the issue with macOS windows opening with the wrong scale.
-rw-r--r--src/core.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core.c b/src/core.c
index 9be1dc06..b8a61d6d 100644
--- a/src/core.c
+++ b/src/core.c
@@ -4258,10 +4258,12 @@ static void SetupViewport(int width, int height)
CORE.Window.render.width = width;
CORE.Window.render.height = height;
- // Set viewport width and height
- // NOTE: We consider render size and offset in case black bars are required and
- // render area does not match full display area (this situation is only applicable on fullscreen mode)
- rlViewport(CORE.Window.renderOffset.x/2, CORE.Window.renderOffset.y/2, CORE.Window.render.width - CORE.Window.renderOffset.x, CORE.Window.render.height - CORE.Window.renderOffset.y);
+ // Set viewport width and height
+ // NOTE: We consider render size (scaled) and offset in case black bars are required and
+ // render area does not match full display area (this situation is only applicable on fullscreen mode)
+ float xScale = 1, yScale = 1;
+ glfwGetWindowContentScale(CORE.Window.handle, &xScale, &yScale);
+ rlViewport(CORE.Window.renderOffset.x/2*xScale, CORE.Window.renderOffset.y/2*yScale, (CORE.Window.render.width - CORE.Window.renderOffset.x)*xScale, (CORE.Window.render.height - CORE.Window.renderOffset.y)*yScale);
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
rlLoadIdentity(); // Reset current matrix (projection)