summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2021-03-20 13:02:44 +0100
committerRay <[email protected]>2021-03-20 13:02:44 +0100
commit95282edaf96f5aaf4c4b40e6631edaf9274b8562 (patch)
tree169461841e5a19dc6bc24da6bf013582ef855f8f /src/core.c
parent75882f32548e564c06a3d14339fabf723601f628 (diff)
downloadraylib-95282edaf96f5aaf4c4b40e6631edaf9274b8562.tar.gz
raylib-95282edaf96f5aaf4c4b40e6631edaf9274b8562.zip
REVIEWED: HighDPI support on macOS retina #1510
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core.c b/src/core.c
index bd099967..de223f4e 100644
--- a/src/core.c
+++ b/src/core.c
@@ -3300,7 +3300,7 @@ static bool InitGraphicsDevice(int width, int height)
// NOTE: This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11.
// On platforms like macOS the resolution of the framebuffer is changed independently of the window size.
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on
- #if !defined(__APPLE__)
+ #if defined(__APPLE__)
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
#endif
}
@@ -3309,6 +3309,7 @@ static bool InitGraphicsDevice(int width, int height)
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
{
+ // NOTE: MSAA is only enabled for main framebuffer, not user-created FBOs
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
glfwWindowHint(GLFW_SAMPLES, 4); // Tries to enable multisampling x4 (MSAA), default is 0
}
@@ -4067,11 +4068,15 @@ static bool InitGraphicsDevice(int width, int height)
#if defined(PLATFORM_DESKTOP)
if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
{
+ // NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling
+ // Framebuffer scaling should be activated with: glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
+ #if !defined(__APPLE__)
glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
// Screen scaling matrix is required in case desired screen area is different than display area
CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f);
- #if !defined(__APPLE__)
+
+ // Mouse input scaling for the new screen size
SetMouseScale((float)CORE.Window.screen.width/fbWidth, (float)CORE.Window.screen.height/fbHeight);
#endif
}