Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos fixes #214

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ else()
endif()

if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/Info.plist
)
execute_process(COMMAND "mkdir -p ${CMAKE_CURRENT_LIST_DIR}/build/Milton.app/Contents/Resources")
execute_process(COMMAND "cp ${CMAKE_CURRENT_LIST_DIR}/milton_icon.icns ${CMAKE_CURRENT_LIST_DIR}/build/Milton.app/Contents/Resources")

target_link_libraries(Milton
"-framework OpenGL"
)
Expand Down
36 changes: 36 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Milton</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string>milton_icon</string>
<key>CFBundleIdentifier</key>
<string></string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundleName</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string></string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
</dict>
</plist>
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ Milton will be compiled to `build\Milton.exe`
This repo provides a binary SDL.lib that was compiled by running
`build_deps.bat` in the `third_party` directory.

macOS
-----
While in the milton top directory
```
mkdir build
cd build
cmake ../
make
```

Should result in a working `Milton.app`.

Linux and macOS
---------------
Expand Down
Binary file added milton_icon.icns
Binary file not shown.
1 change: 1 addition & 0 deletions src/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void* platform_allocate(size_t size);
#define platform_deallocate(pointer) platform_deallocate_internal((void**)&(pointer));
void platform_deallocate_internal(void** ptr);
float platform_ui_scale(PlatformState* p);
float platform_font_scale(PlatformState* p);
void platform_point_to_pixel(PlatformState* ps, v2l* inout);
void platform_point_to_pixel_i(PlatformState* ps, v2i* inout);
void platform_pixel_to_point(PlatformState* ps, v2l* inout);
Expand Down
6 changes: 6 additions & 0 deletions src/platform_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ platform_ui_scale(PlatformState* p)
return 1.0f;
}

float
platform_font_scale(PlatformState* p)
{
return 1.0f;
}

void
platform_pixel_to_point(PlatformState* ps, v2l* inout)
{
Expand Down
6 changes: 6 additions & 0 deletions src/platform_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@
return scale;
}

float
platform_font_scale(PlatformState* p)
{
return 1.0f / p->ui_scale;
}

PATH_CHAR*
platform_open_dialog(FileKind kind)
{
Expand Down
6 changes: 6 additions & 0 deletions src/platform_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ platform_ui_scale(PlatformState* p)
return scale;
}

float
platform_font_scale(PlatformState* p)
{
return 1.0f;
}

void platform_point_to_pixel(PlatformState* ps, v2l* inout)
{

Expand Down
2 changes: 2 additions & 0 deletions src/sdl_milton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,8 @@ milton_main(bool is_fullscreen, char* file_to_open)
platform_fname_at_exe(fname, MAX_PATH);
FILE* fd = platform_fopen(fname, TO_PATH_STR("rb"));

io.FontGlobalScale = platform_font_scale(&platform);

if ( fd ) {
size_t ttf_sz = 0;
void* ttf_data = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/system_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include <string.h>
#include <inttypes.h>

#include <xmmintrin.h>
#include <emmintrin.h>
// #include <xmmintrin.h>
// #include <emmintrin.h>

#if defined(_WIN32)

Expand Down
16 changes: 8 additions & 8 deletions third_party/SDL2-2.0.8/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,14 @@ if(USE_GCC OR USE_CLANG)
endif()
endif()

check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement")
endif()
list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement")
endif()
# check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
# if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
# check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
# if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
# list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement")
# endif()
# list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement")
# endif()

if(DEPENDENCY_TRACKING)
check_c_source_compiles("
Expand Down