summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/SCsub1
-rw-r--r--platform/osx/audio_driver_osx.cpp2
-rw-r--r--platform/osx/audio_driver_osx.h2
-rw-r--r--platform/osx/context_gl_osx.cpp2
-rw-r--r--platform/osx/context_gl_osx.h2
-rw-r--r--platform/osx/detect.py39
-rw-r--r--platform/osx/dir_access_osx.h92
-rw-r--r--platform/osx/dir_access_osx.mm350
-rw-r--r--platform/osx/export/export.cpp31
-rw-r--r--platform/osx/godot_main_osx.mm2
-rw-r--r--platform/osx/godot_osx.h2
-rw-r--r--platform/osx/godot_osx.mm2
-rw-r--r--platform/osx/os_osx.h8
-rw-r--r--platform/osx/os_osx.mm58
-rw-r--r--platform/osx/platform_config.h3
-rw-r--r--platform/osx/sem_osx.cpp2
-rw-r--r--platform/osx/sem_osx.h2
17 files changed, 562 insertions, 38 deletions
diff --git a/platform/osx/SCsub b/platform/osx/SCsub
index 4904636afd..3785eb3fb3 100644
--- a/platform/osx/SCsub
+++ b/platform/osx/SCsub
@@ -6,6 +6,7 @@ files = [
'audio_driver_osx.cpp',
'sem_osx.cpp',
# 'context_gl_osx.cpp',
+ 'dir_access_osx.mm',
]
env.Program('#bin/godot',files)
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp
index 6904b7a398..a74303e6c2 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/platform/osx/audio_driver_osx.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h
index bcf6b23864..92893c64dc 100644
--- a/platform/osx/audio_driver_osx.h
+++ b/platform/osx/audio_driver_osx.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/context_gl_osx.cpp b/platform/osx/context_gl_osx.cpp
index f856e1e4a8..df1c14c643 100644
--- a/platform/osx/context_gl_osx.cpp
+++ b/platform/osx/context_gl_osx.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/context_gl_osx.h b/platform/osx/context_gl_osx.h
index 770ec74737..4a94c20c00 100644
--- a/platform/osx/context_gl_osx.h
+++ b/platform/osx/context_gl_osx.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index 5703cbc546..f7cf5111f5 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -11,15 +11,17 @@ def get_name():
def can_build():
- if (sys.platform != "darwin"):
- return False
+ if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")):
+ return True
- return True # osx enabled
+
+ return False
def get_opts():
return [
('force_64_bits','Force 64 bits binary','no'),
+ ('osxcross_sdk','OSXCross SDK version','darwin14'),
]
@@ -59,12 +61,31 @@ def configure(env):
env.Append(CPPPATH=['#tools/freetype'])
env.Append(CPPPATH=['#tools/freetype/freetype/include'])
- if (env["bits"]=="64"):
- env.Append(CCFLAGS=['-arch', 'x86_64'])
- env.Append(LINKFLAGS=['-arch', 'x86_64'])
+
+
+ if (not os.environ.has_key("OSXCROSS_ROOT")):
+ #regular native build
+ if (env["bits"]=="64"):
+ env.Append(CCFLAGS=['-arch', 'x86_64'])
+ env.Append(LINKFLAGS=['-arch', 'x86_64'])
+ else:
+ env.Append(CCFLAGS=['-arch', 'i386'])
+ env.Append(LINKFLAGS=['-arch', 'i386'])
else:
- env.Append(CCFLAGS=['-arch', 'i386'])
- env.Append(LINKFLAGS=['-arch', 'i386'])
+ #osxcross build
+ root=os.environ.get("OSXCROSS_ROOT",0)
+ if env["bits"]=="64":
+ basecmd=root+"/target/bin/x86_64-apple-"+env["osxcross_sdk"]+"-"
+ else:
+ basecmd=root+"/target/bin/i386-apple-"+env["osxcross_sdk"]+"-"
+
+
+ env['CC'] = basecmd+"cc"
+ env['CXX'] = basecmd+"c++"
+ env['AR'] = basecmd+"ar"
+ env['RANLIB'] = basecmd+"ranlib"
+ env['AS'] = basecmd+"as"
+
# env.Append(CPPPATH=['#platform/osx/include/freetype2', '#platform/osx/include'])
# env.Append(LIBPATH=['#platform/osx/lib'])
@@ -95,4 +116,4 @@ def configure(env):
env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
#env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
-
+ env["x86_opt_gcc"]=True
diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h
new file mode 100644
index 0000000000..caeeaf643c
--- /dev/null
+++ b/platform/osx/dir_access_osx.h
@@ -0,0 +1,92 @@
+/*************************************************************************/
+/* dir_access_unix.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef DIR_ACCESS_OSX_H
+#define DIR_ACCESS_OSX_H
+
+#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include "os/dir_access.h"
+
+
+/**
+ @author Juan Linietsky <reduzio@gmail.com>
+*/
+class DirAccessOSX : public DirAccess {
+
+ DIR *dir_stream;
+
+ static DirAccess *create_fs();
+
+ String current_dir;
+ bool _cisdir;
+ bool _cishidden;
+
+public:
+
+ virtual bool list_dir_begin(); ///< This starts dir listing
+ virtual String get_next();
+ virtual bool current_is_dir() const;
+ virtual bool current_is_hidden() const;
+
+ virtual void list_dir_end(); ///<
+
+ virtual int get_drive_count();
+ virtual String get_drive(int p_drive);
+
+ virtual Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
+ virtual String get_current_dir(); ///< return current dir location
+ virtual Error make_dir(String p_dir);
+
+ virtual bool file_exists(String p_file);
+ virtual bool dir_exists(String p_dir);
+
+ virtual uint64_t get_modified_time(String p_file);
+
+
+
+ virtual Error rename(String p_from, String p_to);
+ virtual Error remove(String p_name);
+
+ virtual size_t get_space_left();
+
+
+ DirAccessOSX();
+ ~DirAccessOSX();
+
+};
+
+
+
+#endif //UNIX ENABLED
+#endif
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm
new file mode 100644
index 0000000000..e345bea60a
--- /dev/null
+++ b/platform/osx/dir_access_osx.mm
@@ -0,0 +1,350 @@
+/*************************************************************************/
+/* dir_access_unix.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "dir_access_osx.h"
+
+#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
+
+#ifndef ANDROID_ENABLED
+#include <sys/statvfs.h>
+#endif
+
+#include <stdio.h>
+#include "os/memory.h"
+#include "print_string.h"
+#include <errno.h>
+
+#include <Foundation/NSString.h>
+
+DirAccess *DirAccessOSX::create_fs() {
+
+ return memnew( DirAccessOSX );
+}
+
+bool DirAccessOSX::list_dir_begin() {
+
+ list_dir_end(); //close any previous dir opening!
+
+
+// char real_current_dir_name[2048]; //is this enough?!
+ //getcwd(real_current_dir_name,2048);
+ //chdir(curent_path.utf8().get_data());
+ dir_stream = opendir(current_dir.utf8().get_data());
+ //chdir(real_current_dir_name);
+ if (!dir_stream)
+ return true; //error!
+
+ return false;
+}
+
+bool DirAccessOSX::file_exists(String p_file) {
+
+ GLOBAL_LOCK_FUNCTION
+
+
+ if (p_file.is_rel_path())
+ p_file=current_dir+"/"+p_file;
+ else
+ p_file=fix_path(p_file);
+
+ struct stat flags;
+ bool success = (stat(p_file.utf8().get_data(),&flags)==0);
+
+ if (success && S_ISDIR(flags.st_mode)) {
+ success=false;
+ }
+
+ return success;
+
+}
+
+bool DirAccessOSX::dir_exists(String p_dir) {
+
+ GLOBAL_LOCK_FUNCTION
+
+
+ if (p_dir.is_rel_path())
+ p_dir=get_current_dir().plus_file(p_dir);
+ else
+ p_dir=fix_path(p_dir);
+
+ struct stat flags;
+ bool success = (stat(p_dir.utf8().get_data(),&flags)==0);
+
+ if (success && S_ISDIR(flags.st_mode))
+ return true;
+
+ return false;
+
+}
+
+uint64_t DirAccessOSX::get_modified_time(String p_file) {
+
+ if (p_file.is_rel_path())
+ p_file=current_dir+"/"+p_file;
+ else
+ p_file=fix_path(p_file);
+
+ struct stat flags;
+ bool success = (stat(p_file.utf8().get_data(),&flags)==0);
+
+ if (success) {
+ return flags.st_mtime;
+ } else {
+
+ ERR_FAIL_V(0);
+ };
+ return 0;
+};
+
+
+String DirAccessOSX::get_next() {
+
+ if (!dir_stream)
+ return "";
+ dirent *entry;
+
+ entry=readdir(dir_stream);
+
+ if (entry==NULL) {
+
+ list_dir_end();
+ return "";
+ }
+
+ //typedef struct stat Stat;
+ struct stat flags;
+
+ String fname;
+ NSString* nsstr = [[NSString stringWithUTF8String: entry->d_name] precomposedStringWithCanonicalMapping];
+
+ fname.parse_utf8([nsstr UTF8String]);
+
+ //[nsstr autorelease];
+
+ String f=current_dir+"/"+fname;
+
+ if (stat(f.utf8().get_data(),&flags)==0) {
+
+ if (S_ISDIR(flags.st_mode)) {
+
+ _cisdir=true;
+
+ } else {
+
+ _cisdir=false;
+ }
+
+ } else {
+
+ _cisdir=false;
+
+ }
+
+ _cishidden=(fname!="." && fname!=".." && fname.begins_with("."));
+
+
+
+ return fname;
+
+}
+
+bool DirAccessOSX::current_is_dir() const {
+
+ return _cisdir;
+}
+
+bool DirAccessOSX::current_is_hidden() const {
+
+ return _cishidden;
+}
+
+
+void DirAccessOSX::list_dir_end() {
+
+ if (dir_stream)
+ closedir(dir_stream);
+ dir_stream=0;
+ _cisdir=false;
+}
+
+int DirAccessOSX::get_drive_count() {
+
+ return 0;
+}
+String DirAccessOSX::get_drive(int p_drive) {
+
+ return "";
+}
+
+Error DirAccessOSX::make_dir(String p_dir) {
+
+ GLOBAL_LOCK_FUNCTION
+
+ p_dir=fix_path(p_dir);
+
+ char real_current_dir_name[2048];
+ getcwd(real_current_dir_name,2048);
+ chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants
+
+ bool success=(mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)==0);
+ int err = errno;
+
+ chdir(real_current_dir_name);
+
+ if (success) {
+ return OK;
+ };
+
+ if (err == EEXIST) {
+ return ERR_ALREADY_EXISTS;
+ };
+
+ return ERR_CANT_CREATE;
+}
+
+
+Error DirAccessOSX::change_dir(String p_dir) {
+
+ GLOBAL_LOCK_FUNCTION
+ p_dir=fix_path(p_dir);
+
+
+ char real_current_dir_name[2048];
+ getcwd(real_current_dir_name,2048);
+ String prev_dir;
+ if (prev_dir.parse_utf8(real_current_dir_name))
+ prev_dir=real_current_dir_name; //no utf8, maybe latin?
+
+ chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants
+ bool worked=(chdir(p_dir.utf8().get_data())==0); // we can only give this utf8
+#ifndef IPHONE_ENABLED
+ String base = _get_root_path();
+ if (base!="") {
+
+ getcwd(real_current_dir_name,2048);
+ String new_dir;
+ new_dir.parse_utf8(real_current_dir_name);
+ if (!new_dir.begins_with(base))
+ worked=false;
+ }
+#endif
+ if (worked) {
+
+ getcwd(real_current_dir_name,2048);
+ if (current_dir.parse_utf8(real_current_dir_name))
+ current_dir=real_current_dir_name; //no utf8, maybe latin?
+ }
+
+ chdir(prev_dir.utf8().get_data());
+ return worked?OK:ERR_INVALID_PARAMETER;
+
+}
+
+String DirAccessOSX::get_current_dir() {
+
+ String base = _get_root_path();
+ if (base!="") {
+
+ String bd = current_dir.replace_first(base,"");
+ if (bd.begins_with("/"))
+ return _get_root_string()+bd.substr(1,bd.length());
+ else
+ return _get_root_string()+bd;
+
+ }
+ return current_dir;
+}
+
+Error DirAccessOSX::rename(String p_path,String p_new_path) {
+
+ if (p_path.is_rel_path())
+ p_path=get_current_dir().plus_file(p_path);
+ else
+ p_path=fix_path(p_path);
+
+ if (p_new_path.is_rel_path())
+ p_new_path=get_current_dir().plus_file(p_new_path);
+ else
+ p_new_path=fix_path(p_new_path);
+
+ return ::rename(p_path.utf8().get_data(),p_new_path.utf8().get_data())==0?OK:FAILED;
+}
+Error DirAccessOSX::remove(String p_path) {
+
+ p_path=fix_path(p_path);
+
+ struct stat flags;
+ if ((stat(p_path.utf8().get_data(),&flags)!=0))
+ return FAILED;
+
+ if (S_ISDIR(flags.st_mode))
+ return ::rmdir(p_path.utf8().get_data())==0?OK:FAILED;
+ else
+ return ::unlink(p_path.utf8().get_data())==0?OK:FAILED;
+}
+
+
+size_t DirAccessOSX::get_space_left() {
+
+#ifndef NO_STATVFS
+ struct statvfs vfs;
+ if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
+
+ return -1;
+ };
+
+ return vfs.f_bfree * vfs.f_bsize;
+#else
+#warning THIS IS BROKEN
+ return 0;
+#endif
+};
+
+
+
+DirAccessOSX::DirAccessOSX() {
+
+ dir_stream=0;
+ current_dir=".";
+ _cisdir=false;
+
+ /* determine drive count */
+
+ change_dir(current_dir);
+
+}
+
+
+DirAccessOSX::~DirAccessOSX() {
+
+ list_dir_end();
+}
+
+
+#endif //posix_enabled
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 885f234a0a..0bece6ec76 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -57,11 +57,11 @@ public:
virtual int get_device_count() const { return 0; };
virtual String get_device_name(int p_device) const { return String(); }
virtual String get_device_info(int p_device) const { return String(); }
- virtual Error run(int p_device,bool p_dumb=false);
+ virtual Error run(int p_device,int p_flags=0);
virtual bool requieres_password(bool p_debug) const { return false; }
virtual String get_binary_extension() const { return "zip"; }
- virtual Error export_project(const String& p_path,bool p_debug,bool p_dumb=false);
+ virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0);
virtual bool can_export(String *r_error=NULL) const;
@@ -245,21 +245,25 @@ void EditorExportPlatformOSX::_fix_plist(Vector<uint8_t>& plist,const String& p_
}
}
-Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug, bool p_dumb) {
+Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug, int p_flags) {
String src_pkg;
EditorProgress ep("export","Exporting for OSX",104);
- String pkg_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/osx.zip";
-
- if (p_debug) {
-
- src_pkg=custom_debug_package!=""?custom_debug_package:pkg_path;
- } else {
-
- src_pkg=custom_release_package!=""?custom_release_package:pkg_path;
+ if (p_debug)
+ src_pkg=custom_debug_package;
+ else
+ src_pkg=custom_release_package;
+
+ if (src_pkg=="") {
+ String err;
+ src_pkg=find_export_template("osx.zip", &err);
+ if (src_pkg=="") {
+ EditorNode::add_io_error(err);
+ return ERR_FILE_NOT_FOUND;
+ }
}
@@ -437,7 +441,7 @@ Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug
}
-Error EditorExportPlatformOSX::run(int p_device, bool p_dumb) {
+Error EditorExportPlatformOSX::run(int p_device, int p_flags) {
return OK;
}
@@ -464,9 +468,8 @@ bool EditorExportPlatformOSX::can_export(String *r_error) const {
bool valid=true;
String err;
- String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/";
- if (!FileAccess::exists(exe_path+"osx.zip")) {
+ if (!exists_export_template("osx.zip")) {
valid=false;
err+="No export templates found.\nDownload and install export templates.\n";
}
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index 92fa6ddbc2..391fd1f74a 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/godot_osx.h b/platform/osx/godot_osx.h
index 270ba9966f..de363d8483 100644
--- a/platform/osx/godot_osx.h
+++ b/platform/osx/godot_osx.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/godot_osx.mm b/platform/osx/godot_osx.mm
index 39119393ff..0c32016216 100644
--- a/platform/osx/godot_osx.mm
+++ b/platform/osx/godot_osx.mm
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 144037b1cb..a1fd34def7 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "os/input.h"
#include "drivers/unix/os_unix.h"
-
+#include "main/input_default.h"
#include "servers/visual_server.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"
@@ -157,6 +157,8 @@ public:
Error shell_open(String p_uri);
void push_input(const InputEvent& p_event);
+ String get_locale() const;
+
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
virtual VideoMode get_video_mode(int p_screen=0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
@@ -170,7 +172,7 @@ public:
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen=0);
+ virtual Point2 get_screen_position(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual void set_window_size(const Size2 p_size);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 72699366c4..2690ee3ba9 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,6 +47,7 @@
#include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
#include "os/keyboard.h"
+#include "dir_access_osx.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -512,12 +513,26 @@ static int button_mask=0;
- (void)mouseExited:(NSEvent *)event
{
+ if (!OS_OSX::singleton)
+ return;
+
+ if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
+ OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
+ if (OS_OSX::singleton->input)
+ OS_OSX::singleton->input->set_mouse_in_window(false);
// _glfwInputCursorEnter(window, GL_FALSE);
}
- (void)mouseEntered:(NSEvent *)event
{
// _glfwInputCursorEnter(window, GL_TRUE);
+ if (!OS_OSX::singleton)
+ return;
+ if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
+ OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
+ if (OS_OSX::singleton->input)
+ OS_OSX::singleton->input->set_mouse_in_window(true);
+
}
- (void)viewDidChangeBackingProperties
@@ -835,6 +850,11 @@ OS::VideoMode OS_OSX::get_default_video_mode() const {
void OS_OSX::initialize_core() {
OS_Unix::initialize_core();
+
+ DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES);
+ DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA);
+ DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
+
SemaphoreOSX::make_default();
}
@@ -1036,6 +1056,33 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
void OS_OSX::finalize() {
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
+ delete_main_loop();
+
+ spatial_sound_server->finish();
+ memdelete(spatial_sound_server);
+ spatial_sound_2d_server->finish();
+ memdelete(spatial_sound_2d_server);
+
+
+ memdelete(input);
+
+ memdelete(sample_manager);
+
+ audio_server->finish();
+ memdelete(audio_server);
+
+ visual_server->finish();
+ memdelete(visual_server);
+ memdelete(rasterizer);
+
+ physics_server->finish();
+ memdelete(physics_server);
+
+ physics_2d_server->finish();
+ memdelete(physics_2d_server);
+
+ screens.clear();
+
}
@@ -1048,6 +1095,8 @@ void OS_OSX::set_main_loop( MainLoop * p_main_loop ) {
void OS_OSX::delete_main_loop() {
+ if (!main_loop)
+ return;
memdelete(main_loop);
main_loop=NULL;
}
@@ -1240,6 +1289,11 @@ Error OS_OSX::shell_open(String p_uri) {
return OK;
}
+String OS_OSX::get_locale() const {
+ NSString* preferredLang = [[NSLocale preferredLanguages] objectAtIndex:0];
+ return [preferredLang UTF8String];
+}
+
void OS_OSX::swap_buffers() {
[context flushBuffer];
@@ -1279,7 +1333,7 @@ void OS_OSX::set_current_screen(int p_screen) {
current_screen = p_screen;
};
-Point2 OS_OSX::get_screen_position(int p_screen) {
+Point2 OS_OSX::get_screen_position(int p_screen) const {
ERR_FAIL_INDEX_V(p_screen, screens.size(), Point2());
return screens[p_screen].pos;
diff --git a/platform/osx/platform_config.h b/platform/osx/platform_config.h
index 285d8d0c02..085f13df73 100644
--- a/platform/osx/platform_config.h
+++ b/platform/osx/platform_config.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,3 +29,4 @@
#include <alloca.h>
#define GLES2_INCLUDE_H "gl_context/glew.h"
#define GLES1_INCLUDE_H "gl_context/glew.h"
+#define PTHREAD_RENAME_SELF
diff --git a/platform/osx/sem_osx.cpp b/platform/osx/sem_osx.cpp
index be70bedf84..6909097fec 100644
--- a/platform/osx/sem_osx.cpp
+++ b/platform/osx/sem_osx.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/osx/sem_osx.h b/platform/osx/sem_osx.h
index 65bed7397f..ec5ddac4e0 100644
--- a/platform/osx/sem_osx.h
+++ b/platform/osx/sem_osx.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */