Merge pull request #36 from rkitover/cmake_xcode_support

fix Xcode project generation via cmake
This commit is contained in:
Christopher Snowhill 2016-11-06 15:41:23 -08:00 committed by GitHub
commit f0e8c94c9c
5 changed files with 52 additions and 36 deletions

View File

@ -97,9 +97,6 @@ IF(APPLE)
ELSEIF(EXISTS /sw/bin) ELSEIF(EXISTS /sw/bin)
SET(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/sw/bin") SET(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/sw/bin")
ENDIF() ENDIF()
# and compile as Objective-C++ for ObjectiveC #ifdefs
SET(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> -x objective-c++ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
ENDIF(APPLE) ENDIF(APPLE)
# We do not support amd64 asm yet # We do not support amd64 asm yet

View File

@ -153,6 +153,10 @@ SET( SRC_WX
xrc/vbam.xpm xrc/vbam.xpm
) )
IF(APPLE)
SET(SRC_WX ${SRC_WX} macsupport.mm)
ENDIF(APPLE)
SET( HDR_WX SET( HDR_WX
wxvbam.h wxvbam.h
drawing.h drawing.h

29
src/wx/macsupport.mm Normal file
View File

@ -0,0 +1,29 @@
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#include "wxvbam.h"
double HiDPIAware::HiDPIScaleFactor()
{
if (hidpi_scale_factor == 0) {
NSWindow* window = [(NSView*)GetWindow()->GetHandle() window];
if ([window respondsToSelector:@selector(backingScaleFactor)]) {
hidpi_scale_factor = [window backingScaleFactor];
}
else {
hidpi_scale_factor = 1.0;
}
}
return hidpi_scale_factor;
}
void HiDPIAware::RequestHighResolutionOpenGLSurface()
{
NSView* view = (NSView*)(GetWindow()->GetHandle());
if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
[view setWantsBestResolutionOpenGLSurface:YES];
}
}

View File

@ -1,10 +1,5 @@
#include <wx/dcbuffer.h> #include <wx/dcbuffer.h>
#ifdef __WXMAC__
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#endif
#include "../../version.h" #include "../../version.h"
#include "../common/ConfigManager.h" #include "../common/ConfigManager.h"
#include "../common/Patch.h" #include "../common/Patch.h"
@ -18,26 +13,6 @@
int emulating; int emulating;
double HiDPIAware::HiDPIScaleFactor()
{
if (hidpi_scale_factor == 0) {
#ifdef __WXMAC__
NSWindow* window = [(NSView*)GetWindow()->GetHandle() window];
if ([window respondsToSelector:@selector(backingScaleFactor)]) {
hidpi_scale_factor = [window backingScaleFactor];
}
else {
hidpi_scale_factor = 1.0;
}
#else
hidpi_scale_factor = 1.0;
#endif
}
return hidpi_scale_factor;
}
IMPLEMENT_DYNAMIC_CLASS(GameArea, wxPanel) IMPLEMENT_DYNAMIC_CLASS(GameArea, wxPanel)
GameArea::GameArea() GameArea::GameArea()
@ -2023,13 +1998,7 @@ GLDrawingPanel::GLDrawingPanel(wxWindow* parent, int _width, int _height)
wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS) wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS)
, DrawingPanel(_width, _height) , DrawingPanel(_width, _height)
{ {
#ifdef __WXMAC__ RequestHighResolutionOpenGLSurface();
NSView* view = (NSView*)GetHandle();
if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
[view setWantsBestResolutionOpenGLSurface:YES];
}
#endif
#if wxCHECK_VERSION(2, 9, 0) #if wxCHECK_VERSION(2, 9, 0)
ctx = new wxGLContext(this); ctx = new wxGLContext(this);
SetCurrent(*ctx); SetCurrent(*ctx);
@ -2479,3 +2448,19 @@ void GameArea::HidePointer()
panel->GetWindow()->SetCursor(wxCursor(wxCURSOR_BLANK)); panel->GetWindow()->SetCursor(wxCursor(wxCURSOR_BLANK));
} }
} }
// stub HiDPI methods, see macsupport.mm for the Mac support
#ifndef __WXMAC__
double HiDPIAware::HiDPIScaleFactor()
{
if (hidpi_scale_factor == 0) {
hidpi_scale_factor = 1.0;
}
return hidpi_scale_factor;
}
void HiDPIAware::RequestHighResolutionOpenGLSurface()
{
}
#endif // HiDPI stubs

View File

@ -345,7 +345,8 @@ private:
// helper class to add HiDPI awareness (mostly for Mac OS X) // helper class to add HiDPI awareness (mostly for Mac OS X)
class HiDPIAware { class HiDPIAware {
public: public:
double HiDPIScaleFactor(); virtual double HiDPIScaleFactor();
virtual void RequestHighResolutionOpenGLSurface();
virtual wxWindow* GetWindow() = 0; virtual wxWindow* GetWindow() = 0;
private: private:
double hidpi_scale_factor = 0; double hidpi_scale_factor = 0;