From aabd8ce66497298783d55a5642ef5a7bbf80d74d Mon Sep 17 00:00:00 2001 From: Grant Paul Date: Sun, 31 Mar 2013 11:36:42 -0700 Subject: [PATCH] Add retina display support for Mac. --- Source/Core/DolphinWX/Info.plist.in | 2 ++ Source/Core/DolphinWX/Src/GLInterface/AGL.cpp | 32 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinWX/Info.plist.in b/Source/Core/DolphinWX/Info.plist.in index 9a05a972c8..c23ae1e40e 100644 --- a/Source/Core/DolphinWX/Info.plist.in +++ b/Source/Core/DolphinWX/Info.plist.in @@ -57,6 +57,8 @@ ${OSX_MIN_VERSION} LSRequiresCarbon + NSHighResolutionCapable + CSResourcesFileMapped diff --git a/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp b/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp index 2fa042daef..bd0e7b2868 100644 --- a/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp +++ b/Source/Core/DolphinWX/Src/GLInterface/AGL.cpp @@ -38,6 +38,17 @@ bool cInterfaceAGL::Create(void *&window_handle) int _tx, _ty, _twidth, _theight; Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight); + GLWin.cocoaWin = (NSView*)(((wxPanel*)window_handle)->GetHandle()); + + // Enable high-resolution display support. + [GLWin.cocoaWin setWantsBestResolutionOpenGLSurface:YES]; + + NSWindow *window = [GLWin.cocoaWin window]; + + float scale = [window backingScaleFactor]; + _twidth *= scale; + _theight *= scale; + // Control window size and picture scaling s_backbuffer_width = _twidth; s_backbuffer_height = _theight; @@ -58,16 +69,14 @@ bool cInterfaceAGL::Create(void *&window_handle) return NULL; } - - GLWin.cocoaWin = (NSView*)(((wxPanel*)window_handle)->GetHandle());; if (GLWin.cocoaWin == nil) { ERROR_LOG(VIDEO, "failed to create window"); return NULL; } - [[GLWin.cocoaWin window] makeFirstResponder:GLWin.cocoaWin]; + [window makeFirstResponder:GLWin.cocoaWin]; [GLWin.cocoaCtx setView: GLWin.cocoaWin]; - [[GLWin.cocoaWin window] makeKeyAndOrderFront: nil]; + [window makeKeyAndOrderFront: nil]; return true; } @@ -88,12 +97,19 @@ void cInterfaceAGL::Shutdown() void cInterfaceAGL::Update() { - if( s_backbuffer_width == [GLWin.cocoaWin frame].size.width - && s_backbuffer_height == [GLWin.cocoaWin frame].size.height) + NSWindow *window = [GLWin.cocoaWin window]; + NSSize size = [GLWin.cocoaWin frame].size; + + float scale = [window backingScaleFactor]; + size.width *= scale; + size.height *= scale; + + if( s_backbuffer_width == size.width + && s_backbuffer_height == size.height) return; - s_backbuffer_width = [GLWin.cocoaWin frame].size.width; - s_backbuffer_height = [GLWin.cocoaWin frame].size.height; + s_backbuffer_width = size.width; + s_backbuffer_height = size.height; [GLWin.cocoaCtx update]; }