Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add retina display support for Mac.
  • Loading branch information
grp committed Mar 31, 2013
1 parent 31500f2 commit aabd8ce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Source/Core/DolphinWX/Info.plist.in
Expand Up @@ -57,6 +57,8 @@
<string>${OSX_MIN_VERSION}</string>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
Expand Down
32 changes: 24 additions & 8 deletions Source/Core/DolphinWX/Src/GLInterface/AGL.cpp
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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];
}
Expand Down

0 comments on commit aabd8ce

Please sign in to comment.