diff --git a/CMakeLists.txt b/CMakeLists.txt index dcc7c59d..60f23022 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ if (APPLE) option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF) option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON) option(GLFW_USE_MENUBAR "Populate the menu bar on first window creation" ON) + option(GLFW_USE_RETINA "Use the full resolution of Retina displays" ON) else() option(GLFW_USE_EGL "Use EGL for context creation" OFF) endif() @@ -340,6 +341,10 @@ if (_GLFW_COCOA AND _GLFW_NSGL) set(_GLFW_USE_CHDIR 1) endif() + if (GLFW_USE_RETINA) + set(_GLFW_USE_RETINA 1) + endif() + if (GLFW_BUILD_UNIVERSAL) message(STATUS "Building GLFW as Universal Binaries") set(CMAKE_OSX_ARCHITECTURES i386;x86_64) diff --git a/README.md b/README.md index 5fc1194e..c41e0aec 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ The following dependencies are needed by the examples and test programs: - Added native monitor handle access to native API - Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files + - [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full + resolution on Retina displays - [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen recorders to fail - [Win32] Bugfix: Failure to load winmm or its functions was not reported to diff --git a/docs/compile.dox b/docs/compile.dox index ef6c3b93..dee7bd9c 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -165,6 +165,9 @@ directory of bundled applications to the `Contents/Resources` directory. `GLFW_USE_MENUBAR` determines whether the first call to `glfwCreateWindow` sets up a minimal menu bar. +`GLFW_USE_RETINA` determines whether windows will use the full resolution of +Retina displays. + `GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries. @@ -257,5 +260,7 @@ available: application bundle during @ref glfwInit (recommended) - `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window is created (recommended) + - `_GLFW_USE_RETINA` to have windows use the full resolution of Retina displays + (recommended) */ diff --git a/src/cocoa_init.m b/src/cocoa_init.m index b6050632..afb1a542 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -132,6 +132,9 @@ const char* _glfwPlatformGetVersionString(void) #if defined(_GLFW_USE_MENUBAR) " menubar" #endif +#if defined(_GLFW_USE_RETINA) + " retina" +#endif #if defined(_GLFW_BUILD_DLL) " dynamic" #endif diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 6e24fe78..b0f59e90 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -940,7 +940,9 @@ static GLboolean createWindow(_GLFWwindow* window, #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) { +#if defined(_GLFW_USE_RETINA) [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; +#endif if (wndconfig->resizable) [window->ns.object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index a7318602..e4953245 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -73,6 +73,8 @@ #cmakedefine _GLFW_USE_CHDIR // Define this to 1 if glfwCreateWindow should populate the menu bar #cmakedefine _GLFW_USE_MENUBAR +// Define this to 1 if windows should use full resolution on Retina displays +#cmakedefine _GLFW_USE_MENUBAR // Define this to 1 if using OpenGL as the client library #cmakedefine _GLFW_USE_OPENGL