From 56448fe58d9ca98716f7fadcc0f3bb127e887c9d Mon Sep 17 00:00:00 2001 From: Ioan Chera Date: Sat, 16 May 2020 14:05:03 +0300 Subject: [PATCH] Fix Dhewm3 displaying wrongly on macOS Retina high-DPI displays It would display on the lower-left quarter. --- neo/sys/glimp.cpp | 8 ++++++-- neo/sys/osx/Info.plist | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index 91b1e065..e3ae0a67 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -95,7 +95,7 @@ bool GLimp_Init(glimpParms_t parms) { assert(SDL_WasInit(SDL_INIT_VIDEO)); - Uint32 flags = SDL_WINDOW_OPENGL; + Uint32 flags = SDL_WINDOW_OPENGL|SDL_WINDOW_ALLOW_HIGHDPI; if (parms.fullScreen) flags |= SDL_WINDOW_FULLSCREEN; @@ -195,7 +195,11 @@ bool GLimp_Init(glimpParms_t parms) { if (SDL_GL_SetSwapInterval(r_swapInterval.GetInteger()) < 0) common->Warning("SDL_GL_SWAP_CONTROL not supported"); - SDL_GetWindowSize(window, &glConfig.vidWidth, &glConfig.vidHeight); + // Use SDL_GL_GetDrawableSize so it also works with macOS high-DPI ("Retina") displays. + SDL_GL_GetDrawableSize(window, &glConfig.vidWidth, &glConfig.vidHeight); + // Fallback + if (!glConfig.vidWidth || !glConfig.vidHeight) + SDL_GetWindowSize(window, &glConfig.vidWidth, &glConfig.vidHeight); SetSDLIcon(); // for SDL2 this must be done after creating the window diff --git a/neo/sys/osx/Info.plist b/neo/sys/osx/Info.plist index 9e1860c4..7f775f37 100644 --- a/neo/sys/osx/Info.plist +++ b/neo/sys/osx/Info.plist @@ -22,5 +22,7 @@ MainMenu NSPrincipalClass NSApplication + NSHighResolutionCapable +