aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-07-26 16:55:46 +0200
committerraysan5 <raysan5@gmail.com>2016-07-26 16:55:46 +0200
commita422e394925e68ab687ef70527c3e207234d8bd7 (patch)
tree2de540e315a0ef4871964fbc2c57e954feaed935 /src
parent07a375e2d626428f5a1b9f02907120a4b3b3a08a (diff)
downloadraylib-a422e394925e68ab687ef70527c3e207234d8bd7.tar.gz
raylib-a422e394925e68ab687ef70527c3e207234d8bd7.zip
Corrected issue on OSX with High DPI display
Many thanks to Marcelo Paez (paezao)
Diffstat (limited to 'src')
-rw-r--r--src/core.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core.c b/src/core.c
index 022fbfe9..0008ef2f 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1612,16 +1612,7 @@ static void InitGraphicsDevice(int width, int height)
{
glfwSwapInterval(1);
TraceLog(INFO, "Trying to enable VSYNC");
- }
-
-#ifdef __APPLE__
- // Get framebuffer size of current window
- // NOTE: Required to handle HighDPI display correctly
- // TODO: Probably should be added for other systems too or managed
- // internally by GLFW3 callback: glfwSetFramebufferSizeCallback()
- glfwGetFramebufferSize(window, &renderWidth, &renderHeight);
-#endif
-
+ }
#endif // defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
@@ -1775,9 +1766,19 @@ static void InitGraphicsDevice(int width, int height)
// NOTE: screenWidth and screenHeight not used, just stored as globals
rlglInit(screenWidth, screenHeight);
+#ifdef __APPLE__
+ // Get framebuffer size of current window
+ // NOTE: Required to handle HighDPI display correctly on OSX because framebuffer
+ // is automatically reasized to adapt to new DPI.
+ // When OS does that, it can be detected using GLFW3 callback: glfwSetFramebufferSizeCallback()
+ int fbWidth, fbHeight;
+ glfwGetFramebufferSize(window, &fbWidth, &fbHeight);
+ rlViewport(renderOffsetX/2, renderOffsetY/2, fbWidth - renderOffsetX, fbHeight - renderOffsetY);
+#else
// Initialize screen viewport (area of the screen that you will actually draw to)
// NOTE: Viewport must be recalculated if screen is resized
rlViewport(renderOffsetX/2, renderOffsetY/2, renderWidth - renderOffsetX, renderHeight - renderOffsetY);
+#endif
// Initialize internal projection and modelview matrices
// NOTE: Default to orthographic projection mode with top-left corner at (0,0)