diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index a1523e90d..d9586c29e 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -117,6 +117,7 @@ typedef struct _GLFWwindowNS id layer; GLFWbool maximized; + GLFWbool retina; // Cached window properties to filter out duplicate events int width, height; diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index b3bc3b84d..fddcee4d4 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -592,14 +592,6 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; _glfwInputWindowDamage(window); } -- (id)makeBackingLayer -{ - if (window->ns.layer) - return window->ns.layer; - - return [super makeBackingLayer]; -} - - (void)cursorUpdate:(NSEvent *)event { updateCursorImage(window); @@ -728,7 +720,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; window->ns.yscale = yscale; _glfwInputWindowContentScale(window, xscale, yscale); - if (window->ns.layer) + if (window->ns.retina && window->ns.layer) [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; } } @@ -1285,8 +1277,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - if (wndconfig->ns.retina) - [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; + window->ns.retina = wndconfig->ns.retina; if (fbconfig->transparent) { @@ -2031,7 +2022,9 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, return VK_ERROR_EXTENSION_NOT_PRESENT; } - [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; + if (window->ns.retina) + [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; + [window->ns.view setLayer:window->ns.layer]; [window->ns.view setWantsLayer:YES]; memset(&sci, 0, sizeof(sci)); diff --git a/glfw/nsgl_context.m b/glfw/nsgl_context.m index ede99a319..cfa398d94 100644 --- a/glfw/nsgl_context.m +++ b/glfw/nsgl_context.m @@ -299,6 +299,9 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, [window->context.nsgl.object setValues:&opaque forParameter:NSOpenGLContextParameterSurfaceOpacity]; } + if (window->ns.retina) + [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; + [window->context.nsgl.object setView:window->ns.view]; window->context.makeCurrent = makeContextCurrentNSGL;