diff options
Diffstat (limited to 'platform')
209 files changed, 2860 insertions, 2501 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index 60bb4bd613..146f7c25a3 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -1,130 +1,132 @@ +#!/usr/bin/env python + import shutil Import('env') android_files = [ - 'os_android.cpp', - 'godot_android.cpp', - 'file_access_android.cpp', - 'dir_access_android.cpp', - 'audio_driver_opensl.cpp', - 'file_access_jandroid.cpp', - 'dir_access_jandroid.cpp', - 'thread_jandroid.cpp', - 'audio_driver_jandroid.cpp', - 'ifaddrs_android.cpp', - 'android_native_app_glue.c', - 'java_glue.cpp', - 'cpu-features.c', - 'java_class_wrapper.cpp' + 'os_android.cpp', + 'godot_android.cpp', + 'file_access_android.cpp', + 'dir_access_android.cpp', + 'audio_driver_opensl.cpp', + 'file_access_jandroid.cpp', + 'dir_access_jandroid.cpp', + 'thread_jandroid.cpp', + 'audio_driver_jandroid.cpp', + 'ifaddrs_android.cpp', + 'android_native_app_glue.c', + 'java_glue.cpp', + 'cpu-features.c', + 'java_class_wrapper.cpp' ] -#env.Depends('#core/math/vector3.h', 'vector3_psp.h') +# env.Depends('#core/math/vector3.h', 'vector3_psp.h') #obj = env.SharedObject('godot_android.cpp') env_android = env.Clone() if env['target'] == "profile": - env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED']) + env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED']) -android_objects=[] +android_objects = [] for x in android_files: - android_objects.append( env_android.SharedObject( x ) ) + android_objects.append(env_android.SharedObject(x)) prog = None -abspath=env.Dir(".").abspath +abspath = env.Dir(".").abspath -gradle_basein = open(abspath+"/build.gradle.template","rb") -gradle_baseout = open(abspath+"/java/build.gradle","wb") +gradle_basein = open(abspath + "/build.gradle.template", "rb") +gradle_baseout = open(abspath + "/java/build.gradle", "wb") gradle_text = gradle_basein.read() -gradle_maven_repos_text="" +gradle_maven_repos_text = "" if len(env.android_maven_repos) > 0: - gradle_maven_repos_text+="maven {\n" - for x in env.android_maven_repos: - gradle_maven_repos_text+="\t\t"+x+"\n" - gradle_maven_repos_text+="\t}\n" + gradle_maven_repos_text += "maven {\n" + for x in env.android_maven_repos: + gradle_maven_repos_text += "\t\t" + x + "\n" + gradle_maven_repos_text += "\t}\n" -gradle_maven_dependencies_text="" +gradle_maven_dependencies_text = "" for x in env.android_dependencies: - gradle_maven_dependencies_text+=x+"\n" + gradle_maven_dependencies_text += x + "\n" -gradle_java_dirs_text="" +gradle_java_dirs_text = "" for x in env.android_java_dirs: - gradle_java_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_java_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_res_dirs_text="" +gradle_res_dirs_text = "" for x in env.android_res_dirs: - gradle_res_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_res_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_aidl_dirs_text="" +gradle_aidl_dirs_text = "" for x in env.android_aidl_dirs: - gradle_aidl_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_aidl_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_jni_dirs_text="" +gradle_jni_dirs_text = "" for x in env.android_jni_dirs: - gradle_jni_dirs_text+=",'"+x.replace("\\","/")+"'" + gradle_jni_dirs_text += ",'" + x.replace("\\", "/") + "'" -gradle_asset_dirs_text="" +gradle_asset_dirs_text = "" -gradle_default_config_text="" +gradle_default_config_text = "" for x in env.android_default_config: - gradle_default_config_text+=x+"\n\t\t" + gradle_default_config_text += x + "\n\t\t" -gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$",gradle_maven_repos_text) -gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$",gradle_maven_dependencies_text) -gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$",gradle_java_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$",gradle_res_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$",gradle_asset_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$",gradle_aidl_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$",gradle_jni_dirs_text) -gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$",gradle_default_config_text) +gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$", gradle_maven_repos_text) +gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$", gradle_maven_dependencies_text) +gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$", gradle_java_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$", gradle_res_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$", gradle_asset_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$", gradle_aidl_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$", gradle_jni_dirs_text) +gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_config_text) -gradle_baseout.write( gradle_text ) +gradle_baseout.write(gradle_text) gradle_baseout.close() -pp_basein = open(abspath+"/AndroidManifest.xml.template","rb") -pp_baseout = open(abspath+"/java/AndroidManifest.xml","wb") +pp_basein = open(abspath + "/AndroidManifest.xml.template", "rb") +pp_baseout = open(abspath + "/java/AndroidManifest.xml", "wb") manifest = pp_basein.read() -manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$",env.android_manifest_chunk) -manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$",env.android_permission_chunk) -manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$",env.android_appattributes_chunk) -pp_baseout.write( manifest ) +manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_chunk) +manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk) +manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$", env.android_appattributes_chunk) +pp_baseout.write(manifest) -env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"]) +env_android.SharedLibrary("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"]) lib_arch_dir = '' if env['android_arch'] == 'armv6': - lib_arch_dir = 'armeabi' + lib_arch_dir = 'armeabi' elif env['android_arch'] == 'armv7': - lib_arch_dir = 'armeabi-v7a' + lib_arch_dir = 'armeabi-v7a' elif env['android_arch'] == 'x86': - lib_arch_dir = 'x86' + lib_arch_dir = 'x86' else: - print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin' + print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin' if lib_arch_dir != '': - if env['target'] == 'release': - lib_type_dir = 'release' - else: # release_debug, debug - lib_type_dir = 'debug' - - out_dir = '#platform/android/java/libs/'+lib_type_dir+'/'+lib_arch_dir - env_android.Command(out_dir+'/libgodot_android.so', '#bin/libgodot'+env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE")) + if env['target'] == 'release': + lib_type_dir = 'release' + else: # release_debug, debug + lib_type_dir = 'debug' + + out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir + env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE")) diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index 419ed977b5..8c57eaaab6 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h index f79057efe5..01ce31be8f 100644 --- a/platform/android/audio_driver_jandroid.h +++ b/platform/android/audio_driver_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index b7ef1424e5..5e3cfcbbab 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index 1b04f32fd2..8839d20bab 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/detect.py b/platform/android/detect.py index 49ffc86658..d1073e0c7b 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -3,248 +3,263 @@ import sys import string import platform + def is_active(): - return True + return True + def get_name(): - return "Android" + return "Android" + def can_build(): - import os - if (not os.environ.has_key("ANDROID_NDK_ROOT")): - return False + import os + if (not os.environ.has_key("ANDROID_NDK_ROOT")): + return False + + return True - return True def get_opts(): - return [ - ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), - ('NDK_TARGET', 'toolchain to use for the NDK',os.environ.get("NDK_TARGET", "arm-linux-androideabi-4.9")), - ('NDK_TARGET_X86', 'toolchain to use for the NDK x86',os.environ.get("NDK_TARGET_X86", "x86-4.9")), - ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)',"android-14"), - ('android_arch', 'select compiler architecture: (armv7/armv6/x86)',"armv7"), - ('android_neon','enable neon (armv7 only)',"yes"), - ('android_stl','enable STL support in android port (for modules)',"no") - ] + return [ + ('ANDROID_NDK_ROOT', 'the path to Android NDK', + os.environ.get("ANDROID_NDK_ROOT", 0)), + ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"), + ('android_arch', 'select compiler architecture: (armv7/armv6/x86)', "armv7"), + ('android_neon', 'enable neon (armv7 only)', "yes"), + ('android_stl', 'enable STL support in android port (for modules)', "no") + ] def get_flags(): - return [ - ('tools', 'no'), - ('nedmalloc', 'no'), - ('builtin_zlib', 'no'), - ('openssl','builtin'), #use builtin openssl - ] + return [ + ('tools', 'no'), + ] def create(env): - tools = env['TOOLS'] - if "mingw" in tools: - tools.remove('mingw') - if "applelink" in tools: - tools.remove("applelink") - env.Tool('gcc') - return env.Clone(tools=tools); + tools = env['TOOLS'] + if "mingw" in tools: + tools.remove('mingw') + if "applelink" in tools: + tools.remove("applelink") + env.Tool('gcc') + return env.Clone(tools=tools) + def configure(env): - # Workaround for MinGW. See: - # http://www.scons.org/wiki/LongCmdLinesOnWin32 - import os - if (os.name=="nt"): - - import subprocess - - def mySubProcess(cmdline,env): - #print "SPAWNED : " + cmdline - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env) - data, err = proc.communicate() - rv = proc.wait() - if rv: - print "=====" - print err - print "=====" - return rv - - def mySpawn(sh, escape, cmd, args, env): - - newargs = ' '.join(args[1:]) - cmdline = cmd + " " + newargs - - rv=0 - if len(cmdline) > 32000 and cmd.endswith("ar") : - cmdline = cmd + " " + args[1] + " " + args[2] + " " - for i in range(3,len(args)) : - rv = mySubProcess( cmdline + args[i], env ) - if rv : - break - else: - rv = mySubProcess( cmdline, env ) - - return rv - - env['SPAWN'] = mySpawn - - ndk_platform=env['ndk_platform'] - - if env['android_arch'] not in ['armv7','armv6','x86']: - env['android_arch']='armv7' - - if env['android_arch']=='x86': - env['NDK_TARGET']=env['NDK_TARGET_X86'] - env["x86_opt_gcc"]=True - - if env['PLATFORM'] == 'win32': - env.Tool('gcc') - env['SHLIBSUFFIX'] = '.so' - - - neon_text="" - if env["android_arch"]=="armv7" and env['android_neon']=='yes': - neon_text=" (with neon)" - print("Godot Android!!!!! ("+env['android_arch']+")"+neon_text) - - env.Append(CPPPATH=['#platform/android']) - - if env['android_arch']=='x86': - env.extra_suffix=".x86"+env.extra_suffix - elif env['android_arch']=='armv6': - env.extra_suffix=".armv6"+env.extra_suffix - elif env["android_arch"]=="armv7": - if env['android_neon']=='yes': - env.extra_suffix=".armv7.neon"+env.extra_suffix - else: - env.extra_suffix=".armv7"+env.extra_suffix - - gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/"; - - if (sys.platform.find("linux")==0): - if (platform.architecture()[0]=='64bit' or os.path.isdir(gcc_path+"linux-x86_64/bin")): # check was not working - gcc_path=gcc_path+"/linux-x86_64/bin" - else: - gcc_path=gcc_path+"/linux-x86/bin" - elif (sys.platform=="darwin"): - gcc_path=gcc_path+"/darwin-x86_64/bin" #this may be wrong - env['SHLINKFLAGS'][1] = '-shared' - env['SHLIBSUFFIX'] = '.so' - elif (os.name=="nt"): - gcc_path=gcc_path+"/windows-x86_64/bin" #this may be wrong - - - - env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH'] - if env['android_arch']=='x86': - env['CC'] = gcc_path+'/i686-linux-android-gcc' - env['CXX'] = gcc_path+'/i686-linux-android-g++' - env['AR'] = gcc_path+"/i686-linux-android-ar" - env['RANLIB'] = gcc_path+"/i686-linux-android-ranlib" - env['AS'] = gcc_path+"/i686-linux-android-as" - else: - env['CC'] = gcc_path+'/arm-linux-androideabi-gcc' - env['CXX'] = gcc_path+'/arm-linux-androideabi-g++' - env['AR'] = gcc_path+"/arm-linux-androideabi-ar" - env['RANLIB'] = gcc_path+"/arm-linux-androideabi-ranlib" - env['AS'] = gcc_path+"/arm-linux-androideabi-as" - - if env['android_arch']=='x86': - env['ARCH'] = 'arch-x86' - else: - env['ARCH'] = 'arch-arm' - - import string - #include path - gcc_include=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH'] +"/usr/include" - ld_sysroot=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH'] - #glue_include=env["ANDROID_NDK_ROOT"]+"/sources/android/native_app_glue" - ld_path=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH']+"/usr/lib" - env.Append(CPPPATH=[gcc_include]) -# env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ') - - env['neon_enabled']=False - if env['android_arch']=='x86': - env['CCFLAGS'] = string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED') - elif env["android_arch"]=="armv6": - env['CCFLAGS'] = string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED') - elif env["android_arch"]=="armv7": - env['CCFLAGS'] = string.split('-DNO_STATVFS -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__ -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED') - if env['android_neon']=='yes': - env['neon_enabled']=True - env.Append(CCFLAGS=['-mfpu=neon','-D__ARM_NEON__']) - else: - env.Append(CCFLAGS=['-mfpu=vfpv3-d16']) - - env.Append(LDPATH=[ld_path]) - env.Append(LIBS=['OpenSLES']) -# env.Append(LIBS=['c','m','stdc++','log','EGL','GLESv1_CM','GLESv2','OpenSLES','supc++','android']) - env.Append(LIBS=['EGL','OpenSLES','android']) - env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2', 'z']) - - env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") - env.Append(LINKFLAGS=["-Wl,-soname,libgodot_android.so"]) - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O2', '-ffast-math','-fomit-frame-pointer']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['-O2', '-ffast-math','-DDEBUG_ENABLED']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) - - env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT']) -# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) - - if(env["opus"]=="yes"): - if (env["android_arch"]=="armv6" or env["android_arch"]=="armv7"): - env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) - env.opus_fixed_point="yes" - - if (env['android_stl']=='yes'): - #env.Append(CCFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/system/include"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/include"]) - if env['android_arch']=='x86': - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86"]) - elif env['android_arch']=='armv6': - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi"]) - elif env["android_arch"]=="armv7": - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"]) - - env.Append(LIBS=["gnustl_static","supc++"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"]) - - #env.Append(CCFLAGS=["-I"+env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/stlport/stlport"]) - #env.Append(CCFLAGS=["-I"+env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include"]) - #env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a"]) - else: - - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/include"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"]) - if env['android_arch']=='x86': - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86"]) - elif env["android_arch"]=="armv6": - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi"]) - elif env["android_arch"]=="armv7": - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"]) - env.Append(LIBS=['gnustl_static']) - env.Append(CCFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST']) - - - import methods - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - - env.use_windows_spawn_fix() + # Workaround for MinGW. See: + # http://www.scons.org/wiki/LongCmdLinesOnWin32 + import os + if (os.name == "nt"): + + import subprocess + + def mySubProcess(cmdline, env): + # print "SPAWNED : " + cmdline + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env) + data, err = proc.communicate() + rv = proc.wait() + if rv: + print "=====" + print err + print "=====" + return rv + + def mySpawn(sh, escape, cmd, args, env): + + newargs = ' '.join(args[1:]) + cmdline = cmd + " " + newargs + + rv = 0 + if len(cmdline) > 32000 and cmd.endswith("ar"): + cmdline = cmd + " " + args[1] + " " + args[2] + " " + for i in range(3, len(args)): + rv = mySubProcess(cmdline + args[i], env) + if rv: + break + else: + rv = mySubProcess(cmdline, env) + + return rv + + env['SPAWN'] = mySpawn + + ndk_platform = env['ndk_platform'] + + if env['android_arch'] not in ['armv7', 'armv6', 'x86']: + env['android_arch'] = 'armv7' + + if env['android_arch'] == 'x86': + env["x86_libtheora_opt_gcc"] = True + + if env['PLATFORM'] == 'win32': + env.Tool('gcc') + env['SHLIBSUFFIX'] = '.so' + + neon_text = "" + if env["android_arch"] == "armv7" and env['android_neon'] == 'yes': + neon_text = " (with neon)" + print("Godot Android!!!!! (" + env['android_arch'] + ")" + neon_text) + + env.Append(CPPPATH=['#platform/android']) + + if env['android_arch'] == 'x86': + env.extra_suffix = ".x86" + env.extra_suffix + target_subpath = "x86-4.9" + abi_subpath = "i686-linux-android" + arch_subpath = "x86" + elif env['android_arch'] == 'armv6': + env.extra_suffix = ".armv6" + env.extra_suffix + target_subpath = "arm-linux-androideabi-4.9" + abi_subpath = "arm-linux-androideabi" + arch_subpath = "armeabi" + elif env["android_arch"] == "armv7": + target_subpath = "arm-linux-androideabi-4.9" + abi_subpath = "arm-linux-androideabi" + arch_subpath = "armeabi-v7a" + if env['android_neon'] == 'yes': + env.extra_suffix = ".armv7.neon" + env.extra_suffix + else: + env.extra_suffix = ".armv7" + env.extra_suffix + + mt_link = True + if (sys.platform.startswith("linux")): + host_subpath = "linux-x86_64" + elif (sys.platform.startswith("darwin")): + host_subpath = "darwin-x86_64" + elif (sys.platform.startswith('win')): + if (platform.machine().endswith('64')): + host_subpath = "windows-x86_64" + else: + mt_link = False + host_subpath = "windows" + + compiler_path = env["ANDROID_NDK_ROOT"] + \ + "/toolchains/llvm/prebuilt/" + host_subpath + "/bin" + gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + \ + "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath + tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin" + + # For Clang to find NDK tools in preference of those system-wide + env.PrependENVPath('PATH', tools_path) + + env['CC'] = compiler_path + '/clang' + env['CXX'] = compiler_path + '/clang++' + env['AR'] = tools_path + "/ar" + env['RANLIB'] = tools_path + "/ranlib" + env['AS'] = tools_path + "/as" + + if env['android_arch'] == 'x86': + env['ARCH'] = 'arch-x86' + else: + env['ARCH'] = 'arch-arm' + + sysroot = env["ANDROID_NDK_ROOT"] + \ + "/platforms/" + ndk_platform + "/" + env['ARCH'] + common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path] + + env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) + env.Append(CPPFLAGS=string.split( + '-Wno-invalid-command-line-argument -Wno-unused-command-line-argument')) + env.Append(CPPFLAGS=string.split( + '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing -Wa,--noexecstack')) + env.Append(CPPFLAGS=string.split('-DANDROID -DNO_STATVFS -DGLES2_ENABLED')) + + env['neon_enabled'] = False + if env['android_arch'] == 'x86': + can_vectorize = True + target_opts = ['-target', 'i686-none-linux-android'] + elif env["android_arch"] == "armv6": + can_vectorize = False + target_opts = ['-target', 'armv6-none-linux-androideabi'] + env.Append(CPPFLAGS=string.split( + '-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp')) + elif env["android_arch"] == "armv7": + can_vectorize = True + target_opts = ['-target', 'armv7-none-linux-androideabi'] + env.Append(CPPFLAGS=string.split( + '-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp')) + if env['android_neon'] == 'yes': + env['neon_enabled'] = True + env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__']) + else: + env.Append(CPPFLAGS=['-mfpu=vfpv3-d16']) + + env.Append(CPPFLAGS=target_opts) + env.Append(CPPFLAGS=common_opts) + + env.Append(LIBS=['OpenSLES']) + env.Append(LIBS=['EGL', 'OpenSLES', 'android']) + env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'z']) + + if (sys.platform.startswith("darwin")): + env['SHLIBSUFFIX'] = '.so' + + env['LINKFLAGS'] = ['-shared', '--sysroot=' + + sysroot, '-Wl,--warn-shared-textrel'] + env.Append(LINKFLAGS=string.split( + '-Wl,--fix-cortex-a8')) + env.Append(LINKFLAGS=string.split( + '-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now')) + env.Append(LINKFLAGS=string.split( + '-Wl,-soname,libgodot_android.so -Wl,--gc-sections')) + if mt_link: + env.Append(LINKFLAGS=['-Wl,--threads']) + env.Append(LINKFLAGS=target_opts) + env.Append(LINKFLAGS=common_opts) + + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/arm-linux-androideabi-4.9/prebuilt/' + + host_subpath + '/lib/gcc/' + abi_subpath + '/4.9.x']) + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + + '/toolchains/arm-linux-androideabi-4.9/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib']) + + if (env["target"].startswith("release")): + env.Append(LINKFLAGS=['-O2']) + env.Append(CPPFLAGS=['-O2', '-DNDEBUG', '-ffast-math', + '-funsafe-math-optimizations', '-fomit-frame-pointer']) + if (can_vectorize): + env.Append(CPPFLAGS=['-ftree-vectorize']) + if (env["target"] == "release_debug"): + env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) + elif (env["target"] == "debug"): + env.Append(LINKFLAGS=['-O0']) + env.Append(CPPFLAGS=['-O0', '-D_DEBUG', '-UNDEBUG', '-DDEBUG_ENABLED', + '-DDEBUG_MEMORY_ALLOC', '-g', '-fno-limit-debug-info']) + + env.Append(CPPFLAGS=['-DANDROID_ENABLED', + '-DUNIX_ENABLED', '-DNO_FCNTL', '-DMPC_FIXED_POINT']) + + # TODO: Move that to opus module's config + if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"): + env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + env.opus_fixed_point = "yes" + + if (env['android_stl'] == 'yes'): + env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + + "/sources/cxx-stl/gnu-libstdc++/4.9/include"]) + env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"]) + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath]) + env.Append(LIBS=["gnustl_static"]) + else: + env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) + + import methods + env.Append(BUILDERS={'GLSL120': env.Builder( + action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder( + action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder( + action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) + + env.use_windows_spawn_fix() diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp index 79ba83b3ee..f1a488cec2 100644 --- a/platform/android/dir_access_android.cpp +++ b/platform/android/dir_access_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/dir_access_android.h b/platform/android/dir_access_android.h index 9477ca48fd..15c29a9a02 100644 --- a/platform/android/dir_access_android.h +++ b/platform/android/dir_access_android.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index be2ffde2cd..bbd041f6c7 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -154,7 +154,7 @@ Error DirAccessJAndroid::change_dir(String p_dir){ String DirAccessJAndroid::get_current_dir(){ - return "/"+current_dir; + return "res://"+current_dir; } bool DirAccessJAndroid::file_exists(String p_file){ @@ -203,7 +203,6 @@ bool DirAccessJAndroid::dir_exists(String p_dir) { return false; env->CallVoidMethod(io,_dir_close,res); - env->DeleteLocalRef(js); return true; } @@ -269,6 +268,6 @@ DirAccessJAndroid::DirAccessJAndroid() { DirAccessJAndroid::~DirAccessJAndroid() { - list_dir_end();; + list_dir_end(); } #endif diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index 356828dcc1..bfd7912aaf 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/export/export.cpp b/platform/android/export/export.cpp index 4735a91f43..0bbb45b8f5 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -190,7 +190,7 @@ NULL}; class EditorExportPlatformAndroid : public EditorExportPlatform { - OBJ_TYPE( EditorExportPlatformAndroid,EditorExportPlatform ); + GDCLASS( EditorExportPlatformAndroid,EditorExportPlatform ); enum { @@ -531,9 +531,9 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { Vector<String> string_table; - printf("stirng block len: %i\n",string_block_len); - printf("stirng count: %i\n",string_count); - printf("flags: %x\n",string_flags); + //printf("stirng block len: %i\n",string_block_len); + //printf("stirng count: %i\n",string_count); + //printf("flags: %x\n",string_flags); for(uint32_t i=0;i<string_count;i++) { @@ -617,7 +617,7 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { p_manifest=ret; - printf("end\n"); + //printf("end\n"); } String EditorExportPlatformAndroid::get_project_name() const { @@ -778,16 +778,16 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool else nspace=""; - printf("ATTR %i NSPACE: %i\n",i,attr_nspace); - printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data()); - printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data()); - printf("ATTR %i FLAGS: %x\n",i,attr_flags); - printf("ATTR %i RESID: %x\n",i,attr_resid); + //printf("ATTR %i NSPACE: %i\n",i,attr_nspace); + //printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data()); + //printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data()); + //printf("ATTR %i FLAGS: %x\n",i,attr_flags); + //printf("ATTR %i RESID: %x\n",i,attr_resid); //replace project information if (tname=="manifest" && attrname=="package") { - print_line("FOUND PACKAGE"); + print_line("FOUND package"); string_table[attr_value]=get_package_name(); } @@ -796,14 +796,14 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool //print_line("attrname: "+attrname); if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionCode") { - print_line("FOUND versioncode"); + print_line("FOUND versionCode"); encode_uint32(version_code,&p_manifest[iofs+16]); } if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionName") { - print_line("FOUND versionname"); + print_line("FOUND versionName"); if (attr_value==0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else @@ -834,10 +834,10 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool } else if (value.begins_with("godot.")) { String perm = value.get_slice(".",1); - print_line("PERM: "+perm+" HAS: "+itos(perms.has(perm))); if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) { + print_line("PERM: "+perm); string_table[attr_value]="android.permission."+perm; } @@ -871,12 +871,12 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool } break; } - printf("chunk %x: size: %d\n",chunk,size); + //printf("chunk %x: size: %d\n",chunk,size); ofs+=size; } - printf("end\n"); + //printf("end\n"); //create new andriodmanifest binary @@ -893,14 +893,14 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool encode_uint32(ofs,&ret[string_table_begins+i*4]); ofs+=string_table[i].length()*2+2+2; - print_line("ofs: "+itos(i)+": "+itos(ofs)); + //print_line("ofs: "+itos(i)+": "+itos(ofs)); } ret.resize(ret.size()+ofs); uint8_t *chars=&ret[ret.size()-ofs]; for(int i=0;i<string_table.size();i++) { String s = string_table[i]; - print_line("savint string :"+s); + //print_line("savint string :"+s); encode_uint16(s.length(),chars); chars+=2; for(int j=0;j<s.length();j++) { //include zero? @@ -934,7 +934,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool encode_uint32(new_stable_end-8,&ret[12]); //update new string table size - print_line("file size: "+itos(ret.size())); + //print_line("file size: "+itos(ret.size())); p_manifest=ret; @@ -949,7 +949,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool header[i]=decode_uint32(&p_manifest[i*4]); } - print_line("STO: "+itos(header[3])); + //print_line("STO: "+itos(header[3])); uint32_t st_offset=9*4; //ERR_FAIL_COND(header[3]!=0x24) uint32_t string_count=header[4]; diff --git a/platform/android/export/export.h b/platform/android/export/export.h index a9421e692e..468b484177 100644 --- a/platform/android/export/export.h +++ b/platform/android/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/file_access_android.cpp b/platform/android/file_access_android.cpp index aefa16ca9c..2828d3c074 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/file_access_android.h b/platform/android/file_access_android.h index 3fcd7836c3..3d54eb2027 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index 3d2e525bbc..4755f1d029 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h index d576af93d6..38f441ea71 100644 --- a/platform/android/file_access_jandroid.h +++ b/platform/android/file_access_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp index 9a4252bde0..3ec1094ee1 100644 --- a/platform/android/globals/global_defaults.cpp +++ b/platform/android/globals/global_defaults.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/globals/global_defaults.h b/platform/android/globals/global_defaults.h index 6f240572d8..49d7f6393c 100644 --- a/platform/android/globals/global_defaults.h +++ b/platform/android/globals/global_defaults.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/godot_android.cpp b/platform/android/godot_android.cpp index 2371274d9d..4ef6619146 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -57,7 +57,7 @@ extern "C" { class JNISingleton : public Object { - OBJ_TYPE( JNISingleton, Object ); + GDCLASS( JNISingleton, Object ); struct MethodData { diff --git a/platform/android/java/src/org/godotengine/godot/Dictionary.java b/platform/android/java/src/org/godotengine/godot/Dictionary.java index e003c245bb..72f0b7a60e 100644 --- a/platform/android/java/src/org/godotengine/godot/Dictionary.java +++ b/platform/android/java/src/org/godotengine/godot/Dictionary.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 4b80db7e33..d2533378dc 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -295,6 +295,25 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC }); } } + + public void alert(final String message, final String title) { + runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(getInstance()); + builder.setMessage(message).setTitle(title); + builder.setPositiveButton( + "OK", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); + AlertDialog dialog = builder.create(); + dialog.show(); + } + }); + } private static Godot _self; diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java index ea6c070fae..5a07d680b3 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java +++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java index 4ea3f13021..878528f7c7 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java +++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index 55e330924a..33c1c03ace 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -288,6 +288,11 @@ public class GodotIO { try { ad.files = am.list(path); + // no way to find path is directory or file exactly. + // but if ad.files.length==0, then it's an empty directory or file. + if (ad.files.length==0) { + return -1; + } } catch (IOException e) { System.out.printf("Exception on dir_open: %s\n",e); diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java index 9a2ea7df10..57856cfd6b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java index b7de31ada3..6eee8da91b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java +++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java index e210161e8b..db67144bcc 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/src/org/godotengine/godot/GodotView.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java index aa92eeae0f..f0dae03a81 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java index 13c8c8b3ec..80cded6fb5 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java index 16b669fbe8..13a24994f8 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java index 175d401c87..20feaef581 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java index e63230c4f8..1aa210265d 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/PaymentsCache.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java index 0635385f53..88fd1a0fe4 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java index 753c0a6f93..73d1cc3bc8 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java index 9e92d8b5a5..d154ef0c78 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java index 2dc7dcf6b1..c74269890d 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java index f3532f311f..dafab13ad7 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java index ef7793c1e6..f8936bef2b 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java +++ b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java index f2b0e8786e..823c75d186 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java +++ b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java index 5687b3c1e1..9dd08a9563 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java +++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java/src/org/godotengine/godot/utils/RequestParams.java b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java index d66dfe9531..bb00f1f468 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java +++ b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index cc1e5b61d1..296ac0a831 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -562,7 +562,7 @@ JavaObject::~JavaObject(){ void JavaClassWrapper::_bind_methods() { - ObjectTypeDB::bind_method(_MD("wrap:JavaClass","name"),&JavaClassWrapper::wrap); + ClassDB::bind_method(_MD("wrap:JavaClass","name"),&JavaClassWrapper::wrap); } diff --git a/platform/android/java_class_wrapper.h b/platform/android/java_class_wrapper.h index 012e7854fe..ff213c7f33 100644 --- a/platform/android/java_class_wrapper.h +++ b/platform/android/java_class_wrapper.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -37,7 +37,7 @@ class JavaObject; class JavaClass : public Reference { - OBJ_TYPE(JavaClass,Reference); + GDCLASS(JavaClass,Reference); enum ArgumentType { @@ -131,7 +131,7 @@ public: class JavaObject : public Reference { - OBJ_TYPE(JavaObject,Reference); + GDCLASS(JavaObject,Reference); Ref<JavaClass> base_class; friend class JavaClass; @@ -150,7 +150,7 @@ public: class JavaClassWrapper : public Object { - OBJ_TYPE(JavaClassWrapper,Object); + GDCLASS(JavaClassWrapper,Object); Map<String,Ref<JavaClass> > class_cache; diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index e5b655e5d5..c8dc3ce3c3 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -410,7 +410,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { class JNISingleton : public Object { - OBJ_TYPE( JNISingleton, Object ); + GDCLASS( JNISingleton, Object ); struct MethodData { @@ -679,6 +679,7 @@ static jmethodID _isVideoPlaying=0; static jmethodID _pauseVideo=0; static jmethodID _stopVideo=0; static jmethodID _setKeepScreenOn=0; +static jmethodID _alertDialog=0; static void _gfx_init_func(void* ud, bool gl2) { @@ -783,6 +784,13 @@ static void _set_keep_screen_on(bool p_enabled) { env->CallVoidMethod(_godot_instance, _setKeepScreenOn, p_enabled); } +static void _alert(const String& p_message, const String& p_title) { + JNIEnv* env = ThreadAndroid::get_env(); + jstring jStrMessage = env->NewStringUTF(p_message.utf8().get_data()); + jstring jStrTitle = env->NewStringUTF(p_title.utf8().get_data()); + env->CallVoidMethod(_godot_instance, _alertDialog, jStrMessage, jStrTitle); +} + JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline,jobject p_asset_manager) { __android_log_print(ANDROID_LOG_INFO,"godot","**INIT EVENT! - %p\n",env); @@ -820,6 +828,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e _on_video_init = env->GetMethodID(cls, "onVideoInit", "(Z)V"); _setKeepScreenOn = env->GetMethodID(cls,"setKeepScreenOn","(Z)V"); + _alertDialog = env->GetMethodID(cls,"alert","(Ljava/lang/String;Ljava/lang/String;)V"); jclass clsio = env->FindClass("org/godotengine/godot/Godot"); if (cls) { @@ -883,7 +892,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e __android_log_print(ANDROID_LOG_INFO,"godot","CMDLINE LEN %i - APK EXPANSION %I\n",cmdlen,int(use_apk_expansion)); - os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, use_apk_expansion); + os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, use_apk_expansion); os_android->set_need_reload_hooks(p_need_reload_hook); char wd[500]; diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index f1c83f01e8..bc4628b9d4 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/os_android.cpp b/platform/android/os_android.cpp index 862709fc7d..54af4cde13 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -246,9 +246,11 @@ void OS_Android::print(const char *p_format, ... ) { } -void OS_Android::alert(const String& p_alert) { +void OS_Android::alert(const String& p_alert,const String& p_title) { print("ALERT: %s\n",p_alert.utf8().get_data()); + if (alert_func) + alert_func(p_alert, p_title); } @@ -812,7 +814,7 @@ String OS_Android::get_joy_guid(int p_device) const { return input->get_joy_guid_remapped(p_device); } -OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion) { +OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion) { use_apk_expansion=p_use_apk_expansion; default_videomode.width=800; @@ -846,6 +848,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu set_screen_orientation_func=p_screen_orient; set_keep_screen_on_func = p_set_keep_screen_on_func; + alert_func = p_alert_func; use_reload_hooks=false; } diff --git a/platform/android/os_android.h b/platform/android/os_android.h index d383fd2036..68b50b2087 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -75,6 +75,7 @@ typedef bool (*VideoIsPlayingFunc)(); typedef void (*VideoPauseFunc)(); typedef void (*VideoStopFunc)(); typedef void (*SetKeepScreenOnFunc)(bool p_enabled); +typedef void (*AlertFunc)(const String&, const String&); class OS_Android : public OS_Unix { public: @@ -154,6 +155,7 @@ private: VideoPauseFunc video_pause_func; VideoStopFunc video_stop_func; SetKeepScreenOnFunc set_keep_screen_on_func; + AlertFunc alert_func; public: @@ -181,7 +183,7 @@ public: virtual void vprint(const char* p_format, va_list p_list, bool p_stderr=false); virtual void print(const char *p_format, ... ); - virtual void alert(const String& p_alert); + virtual void alert(const String& p_alert,const String& p_title="ALERT!"); virtual void set_mouse_show(bool p_show); @@ -260,7 +262,7 @@ public: virtual String get_joy_guid(int p_device) const; void joy_connection_changed(int p_device, bool p_connected, String p_name); - OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion); + OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion); ~OS_Android(); }; diff --git a/platform/android/platform_config.h b/platform/android/platform_config.h index 143f16c1fa..cdef185ff0 100644 --- a/platform/android/platform_config.h +++ b/platform/android/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 73818b282f..aa40d995d9 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/android/thread_jandroid.h b/platform/android/thread_jandroid.h index c8ad6c8735..6f52b730f1 100644 --- a/platform/android/thread_jandroid.h +++ b/platform/android/thread_jandroid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/SCsub b/platform/bb10/SCsub index 81f6e726e4..c19f46d579 100644 --- a/platform/bb10/SCsub +++ b/platform/bb10/SCsub @@ -1,20 +1,22 @@ +#!/usr/bin/env python + Import('env') bb10_lib = [ - 'bbutil.c', - 'os_bb10.cpp', - 'audio_driver_bb10.cpp', - 'godot_bb10.cpp', - 'payment_service.cpp', + 'bbutil.c', + 'os_bb10.cpp', + 'audio_driver_bb10.cpp', + 'godot_bb10.cpp', + 'payment_service.cpp', ] env_bps = env.Clone() if env['bb10_payment_service'] == "yes": - env_bps.Append(CPPFLAGS=['-DPAYMENT_SERVICE_ENABLED']) + env_bps.Append(CPPFLAGS=['-DPAYMENT_SERVICE_ENABLED']) if env['bb10_lgles_override'] == "yes": - env_bps.Append(CPPFLAGS=['-DBB10_LGLES_OVERRIDE']) + env_bps.Append(CPPFLAGS=['-DBB10_LGLES_OVERRIDE']) prog = None diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp index ef8adaf061..7b5c0800a8 100644 --- a/platform/bb10/audio_driver_bb10.cpp +++ b/platform/bb10/audio_driver_bb10.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h index 0148448511..738bcf2619 100644 --- a/platform/bb10/audio_driver_bb10.h +++ b/platform/bb10/audio_driver_bb10.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/detect.py b/platform/bb10/detect.py index 9ab94e619a..d3ee9f0124 100644 --- a/platform/bb10/detect.py +++ b/platform/bb10/detect.py @@ -5,87 +5,88 @@ import methods def is_active(): - return True + return True + def get_name(): - return "BlackBerry 10" + return "BlackBerry 10" + def can_build(): - import os - if (not os.environ.has_key("QNX_TARGET")): - return False - return True + import os + if (not os.environ.has_key("QNX_TARGET")): + return False + return True + def get_opts(): - return [ - ('QNX_HOST', 'path to qnx host', os.environ.get("QNX_HOST", 0)), - ('QNX_TARGET', 'path to qnx target', os.environ.get("QNX_TARGET", 0)), - ('QNX_CONFIGURATION', 'path to qnx configuration', os.environ.get("QNX_CONFIGURATION", 0)), - ('qnx_target', 'Qnx target (armle or x86', 'armle'), - ('bb10_payment_service', 'Enable Payment Service for BlackBerry10', 'yes'), - ('bb10_lgles_override', 'Force legacy GLES (1.1) on iOS', 'no'), - ('bb10_exceptions', 'Use exceptions when compiling on bb10', 'no'), - ] + return [ + ('QNX_HOST', 'path to qnx host', os.environ.get("QNX_HOST", 0)), + ('QNX_TARGET', 'path to qnx target', os.environ.get("QNX_TARGET", 0)), + ('QNX_CONFIGURATION', 'path to qnx configuration', os.environ.get("QNX_CONFIGURATION", 0)), + ('qnx_target', 'Qnx target (armle or x86', 'armle'), + ('bb10_payment_service', 'Enable Payment Service for BlackBerry10', 'yes'), + ('bb10_lgles_override', 'Force legacy GLES (1.1) on iOS', 'no'), + ('bb10_exceptions', 'Use exceptions when compiling on bb10', 'no'), + ] + def get_flags(): - return [ - ('lua', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('theora', 'no'), + return [ + ('tools', 'no'), + ('module_theora_enabled', 'no'), + ] - ] def configure(env): - if env['PLATFORM'] == 'win32': - env.Tool('mingw') - env['SPAWN'] = methods.win32_spawn - - env['qnx_target_ver'] = env['qnx_target'] - if env['qnx_target'] == "armle": - env['qnx_prefix'] = 'ntoarmv7' - env['qnx_target_ver'] = 'armle-v7' - else: - env['qnx_prefix'] = 'ntox86' + if env['PLATFORM'] == 'win32': + env.Tool('mingw') + env['SPAWN'] = methods.win32_spawn - env['OBJSUFFIX'] = ".qnx.${qnx_target}.o" - env['LIBSUFFIX'] = ".qnx.${qnx_target}.a" - env['PROGSUFFIX'] = ".qnx.${qnx_target}" - print("PROGSUFFIX: "+env['PROGSUFFIX']+" target: "+env['qnx_target']) + env['qnx_target_ver'] = env['qnx_target'] + if env['qnx_target'] == "armle": + env['qnx_prefix'] = 'ntoarmv7' + env['qnx_target_ver'] = 'armle-v7' + else: + env['qnx_prefix'] = 'ntox86' - env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/bin') - env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/usr/bin') - env['ENV']['QNX_HOST'] = env['QNX_HOST'] - env['ENV']['QNX_TARGET'] = env['QNX_TARGET'] - env['ENV']['QNX_CONFIGURATION'] = env['QNX_CONFIGURATION'] + env['OBJSUFFIX'] = ".qnx.${qnx_target}.o" + env['LIBSUFFIX'] = ".qnx.${qnx_target}.a" + env['PROGSUFFIX'] = ".qnx.${qnx_target}" + print("PROGSUFFIX: " + env['PROGSUFFIX'] + " target: " + env['qnx_target']) - env['CC'] = '$qnx_prefix-gcc' - env['CXX'] = '$qnx_prefix-g++' - env['AR'] = '$qnx_prefix-ar' - env['RANLIB'] = '$qnx_prefix-ranlib' + env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/bin') + env.PrependENVPath('PATH', env['QNX_CONFIGURATION'] + '/usr/bin') + env['ENV']['QNX_HOST'] = env['QNX_HOST'] + env['ENV']['QNX_TARGET'] = env['QNX_TARGET'] + env['ENV']['QNX_CONFIGURATION'] = env['QNX_CONFIGURATION'] - env.Append(CPPPATH = ['#platform/bb10']) - env.Append(LIBPATH = ['#platform/bb10/lib/$qnx_target', '#platform/bb10/lib/$qnx_target_ver']) - env.Append(CCFLAGS = string.split('-DBB10_ENABLED -DUNIX_ENABLED -DGLES2_ENABLED -DGLES1_ENABLED -D_LITTLE_ENDIAN -DNO_THREADS -DNO_FCNTL')) - if env['bb10_exceptions']=="yes": - env.Append(CCFLAGS = ['-fexceptions']) - else: - env.Append(CCFLAGS = ['-fno-exceptions']) + env['CC'] = '$qnx_prefix-gcc' + env['CXX'] = '$qnx_prefix-g++' + env['AR'] = '$qnx_prefix-ar' + env['RANLIB'] = '$qnx_prefix-ranlib' - #env.Append(LINKFLAGS = string.split() + env.Append(CPPPATH=['#platform/bb10']) + env.Append(LIBPATH=['#platform/bb10/lib/$qnx_target', '#platform/bb10/lib/$qnx_target_ver']) + env.Append(CCFLAGS=string.split('-DBB10_ENABLED -DUNIX_ENABLED -DGLES2_ENABLED -DGLES1_ENABLED -D_LITTLE_ENDIAN -DNO_THREADS -DNO_FCNTL')) + if env['bb10_exceptions'] == "yes": + env.Append(CCFLAGS=['-fexceptions']) + else: + env.Append(CCFLAGS=['-fno-exceptions']) - if (env["target"]=="release"): + # env.Append(LINKFLAGS = string.split() - env.Append(CCFLAGS=['-O3','-DRELEASE_BUILD']) + if (env["target"] == "release"): - elif (env["target"]=="debug"): + env.Append(CCFLAGS=['-O3', '-DRELEASE_BUILD']) - env.Append(CCFLAGS=['-g', '-O0','-DDEBUG_ENABLED', '-D_DEBUG']) - env.Append(LINKFLAGS=['-g']) + elif (env["target"] == "debug"): - env.Append(LIBS=['bps', 'pps', 'screen', 'socket', 'EGL', 'GLESv2', 'GLESv1_CM', 'm', 'asound']) + env.Append(CCFLAGS=['-g', '-O0', '-DDEBUG_ENABLED', '-D_DEBUG']) + env.Append(LINKFLAGS=['-g']) + env.Append(LIBS=['bps', 'pps', 'screen', 'socket', 'EGL', 'GLESv2', 'GLESv1_CM', 'm', 'asound']) diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index 14d87aef41..a79d0807aa 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -43,7 +43,7 @@ class EditorExportPlatformBB10 : public EditorExportPlatform { - OBJ_TYPE( EditorExportPlatformBB10,EditorExportPlatform ); + GDCLASS( EditorExportPlatformBB10,EditorExportPlatform ); String custom_package; diff --git a/platform/bb10/export/export.h b/platform/bb10/export/export.h index bd9cad5cb3..d8407c4152 100644 --- a/platform/bb10/export/export.h +++ b/platform/bb10/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/godot_bb10.cpp b/platform/bb10/godot_bb10.cpp index cba9d200cb..4b8270b495 100644 --- a/platform/bb10/godot_bb10.cpp +++ b/platform/bb10/godot_bb10.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index 58ea26b8c9..ed40355eb5 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/os_bb10.h b/platform/bb10/os_bb10.h index 4ee5af8323..8011550987 100644 --- a/platform/bb10/os_bb10.h +++ b/platform/bb10/os_bb10.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/bb10/payment_service.cpp b/platform/bb10/payment_service.cpp index 77ec122b3b..3138dc2c1d 100644 --- a/platform/bb10/payment_service.cpp +++ b/platform/bb10/payment_service.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -38,11 +38,11 @@ extern char* launch_dir_ptr; void PaymentService::_bind_methods() { - ObjectTypeDB::bind_method(_MD("request_product_info"),&PaymentService::request_product_info); - ObjectTypeDB::bind_method(_MD("purchase"),&PaymentService::purchase); + ClassDB::bind_method(_MD("request_product_info"),&PaymentService::request_product_info); + ClassDB::bind_method(_MD("purchase"),&PaymentService::purchase); - ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&PaymentService::get_pending_event_count); - ObjectTypeDB::bind_method(_MD("pop_pending_event"),&PaymentService::pop_pending_event); + ClassDB::bind_method(_MD("get_pending_event_count"),&PaymentService::get_pending_event_count); + ClassDB::bind_method(_MD("pop_pending_event"),&PaymentService::pop_pending_event); }; Error PaymentService::request_product_info(Variant p_params) { diff --git a/platform/bb10/payment_service.h b/platform/bb10/payment_service.h index 856b8df306..b31a954ef8 100644 --- a/platform/bb10/payment_service.h +++ b/platform/bb10/payment_service.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -39,7 +39,7 @@ class PaymentService : public Object { - OBJ_TYPE(PaymentService, Object); + GDCLASS(PaymentService, Object); static void _bind_methods(); diff --git a/platform/bb10/platform_config.h b/platform/bb10/platform_config.h index 143f16c1fa..cdef185ff0 100644 --- a/platform/bb10/platform_config.h +++ b/platform/bb10/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/SCsub b/platform/haiku/SCsub index 1952e6b59b..d0c244a194 100644 --- a/platform/haiku/SCsub +++ b/platform/haiku/SCsub @@ -1,25 +1,28 @@ +#!/usr/bin/env python + Import('env') common_haiku = [ - 'os_haiku.cpp', - 'context_gl_haiku.cpp', - 'haiku_application.cpp', - 'haiku_direct_window.cpp', - 'haiku_gl_view.cpp', - 'key_mapping_haiku.cpp', - 'audio_driver_media_kit.cpp' + 'os_haiku.cpp', + 'context_gl_haiku.cpp', + 'haiku_application.cpp', + 'haiku_direct_window.cpp', + 'haiku_gl_view.cpp', + 'key_mapping_haiku.cpp', + 'audio_driver_media_kit.cpp' ] target = env.Program( - '#bin/godot', - ['godot_haiku.cpp'] + common_haiku + '#bin/godot', + ['godot_haiku.cpp'] + common_haiku ) command = env.Command('#bin/godot.rsrc', '#platform/haiku/godot.rdef', - ['rc -o $TARGET $SOURCE']) + ['rc -o $TARGET $SOURCE']) + -def addResourcesAction(target = None, source = None, env = None): - return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc') +def addResourcesAction(target=None, source=None, env=None): + return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc') env.AddPostAction(target, addResourcesAction) env.Depends(target, command) diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index c7eed1c7cd..2af93061f8 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h index cdaf602831..fbf6bc20de 100644 --- a/platform/haiku/audio_driver_media_kit.h +++ b/platform/haiku/audio_driver_media_kit.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp index bf890d14bf..c43e3f3928 100644 --- a/platform/haiku/context_gl_haiku.cpp +++ b/platform/haiku/context_gl_haiku.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h index c7f80543aa..1fd62e89ba 100644 --- a/platform/haiku/context_gl_haiku.h +++ b/platform/haiku/context_gl_haiku.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/detect.py b/platform/haiku/detect.py index f36b0c567e..71202a9a49 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -1,63 +1,67 @@ import os import sys + def is_active(): - return True + return True + def get_name(): - return "Haiku" + return "Haiku" + def can_build(): - if (os.name != "posix"): - return False + if (os.name != "posix"): + return False - if (sys.platform == "darwin"): - return False + if (sys.platform == "darwin"): + return False + + return True - return True def get_opts(): - return [ - ('debug_release', 'Add debug symbols to release version','no') - ] + return [ + ('debug_release', 'Add debug symbols to release version', 'no') + ] + def get_flags(): - return [ - ('builtin_zlib', 'no'), - ('glew', 'yes'), - ] + return [ + ] + def configure(env): - is64 = sys.maxsize > 2**32 - - if (env["bits"]=="default"): - if (is64): - env["bits"]="64" - else: - env["bits"]="32" - - env.Append(CPPPATH = ['#platform/haiku']) - - env["CC"] = "gcc-x86" - env["CXX"] = "g++-x86" - - if (env["target"]=="release"): - if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2']) - else: - env.Append(CCFLAGS=['-O3','-ffast-math']) - elif (env["target"]=="release_debug"): - env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - - #env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) - env.Append(CPPFLAGS = ['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np - env.Append(CPPFLAGS = ['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) - env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) - env.Append(LIBS = ['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) - - import methods - env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) - env.Append(BUILDERS = {'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) - env.Append(BUILDERS = {'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl')}) + is64 = sys.maxsize > 2**32 + + if (env["bits"] == "default"): + if (is64): + env["bits"] = "64" + else: + env["bits"] = "32" + + env.Append(CPPPATH=['#platform/haiku']) + + env["CC"] = "gcc-x86" + env["CXX"] = "g++-x86" + + if (env["target"] == "release"): + if (env["debug_release"] == "yes"): + env.Append(CCFLAGS=['-g2']) + else: + env.Append(CCFLAGS=['-O3', '-ffast-math']) + elif (env["target"] == "release_debug"): + env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) + elif (env["target"] == "debug"): + env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + # env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np + env.Append(CPPFLAGS=['-DOPENGL_ENABLED', '-DMEDIA_KIT_ENABLED']) + env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) + env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) + + import methods + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/haiku/godot_haiku.cpp b/platform/haiku/godot_haiku.cpp index 71c9d30239..fccfa4336f 100644 --- a/platform/haiku/godot_haiku.cpp +++ b/platform/haiku/godot_haiku.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp index 2b9604f563..1f35c6f58e 100644 --- a/platform/haiku/haiku_application.cpp +++ b/platform/haiku/haiku_application.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/haiku_application.h b/platform/haiku/haiku_application.h index 74316b9b1f..d85e6e4829 100644 --- a/platform/haiku/haiku_application.h +++ b/platform/haiku/haiku_application.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 583453af1e..1def361367 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index b4fdb6edb2..49785f79cb 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp index da0957c81d..66c143ea67 100644 --- a/platform/haiku/haiku_gl_view.cpp +++ b/platform/haiku/haiku_gl_view.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h index 05c288e83b..6d64aab42e 100644 --- a/platform/haiku/haiku_gl_view.h +++ b/platform/haiku/haiku_gl_view.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp index 43981b8855..f41a77c3fb 100644 --- a/platform/haiku/key_mapping_haiku.cpp +++ b/platform/haiku/key_mapping_haiku.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/key_mapping_haiku.h b/platform/haiku/key_mapping_haiku.h index 1309ee034d..81f5569fd0 100644 --- a/platform/haiku/key_mapping_haiku.h +++ b/platform/haiku/key_mapping_haiku.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index f5674fb0eb..10e1b055be 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/os_haiku.h b/platform/haiku/os_haiku.h index e1d6b5b7b9..fc873f49ad 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/haiku/platform_config.h b/platform/haiku/platform_config.h index 72dc0e5149..527dc9de06 100644 --- a/platform/haiku/platform_config.h +++ b/platform/haiku/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/SCsub b/platform/iphone/SCsub index 5b2e1533da..38f789259c 100644 --- a/platform/iphone/SCsub +++ b/platform/iphone/SCsub @@ -1,34 +1,36 @@ +#!/usr/bin/env python + Import('env') iphone_lib = [ - 'os_iphone.cpp', - #'rasterizer_iphone.cpp', - 'audio_driver_iphone.cpp', - 'sem_iphone.cpp', - 'gl_view.mm', - 'main.m', - 'app_delegate.mm', - 'view_controller.mm', - 'game_center.mm', - 'in_app_store.mm', - 'icloud.mm', - #'Appirater.m', - 'ios.mm', + 'os_iphone.cpp', + #'rasterizer_iphone.cpp', + 'audio_driver_iphone.cpp', + 'sem_iphone.cpp', + 'gl_view.mm', + 'main.m', + 'app_delegate.mm', + 'view_controller.mm', + 'game_center.mm', + 'in_app_store.mm', + 'icloud.mm', + #'Appirater.m', + 'ios.mm', ] -#env.Depends('#core/math/vector3.h', 'vector3_psp.h') +# env.Depends('#core/math/vector3.h', 'vector3_psp.h') #iphone_lib = env.Library('iphone', iphone_lib) -env_ios = env.Clone(); +env_ios = env.Clone() if env['ios_gles22_override'] == "yes": - env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE']) + env_ios.Append(CPPFLAGS=['-DGLES2_OVERRIDE']) -#if env['ios_appirater'] == "yes": +# if env['ios_appirater'] == "yes": # env_ios.Append(CPPFLAGS=['-DAPPIRATER_ENABLED']) @@ -36,5 +38,5 @@ obj = env_ios.Object('godot_iphone.cpp') prog = None prog = env_ios.Program('#bin/godot', [obj] + iphone_lib) -action = "$IPHONEPATH/usr/bin/dsymutil "+File(prog)[0].path+" -o " + File(prog)[0].path + ".dSYM" +action = "$IPHONEPATH/usr/bin/dsymutil " + File(prog)[0].path + " -o " + File(prog)[0].path + ".dSYM" env.AddPostAction(prog, action) diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h index 54bfe78cf7..09c401b329 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/iphone/app_delegate.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index dab75e08c8..86c3eecd47 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp index 0916c31f36..556576cdc3 100644 --- a/platform/iphone/audio_driver_iphone.cpp +++ b/platform/iphone/audio_driver_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h index 0b143adf94..cbcb0cffce 100644 --- a/platform/iphone/audio_driver_iphone.h +++ b/platform/iphone/audio_driver_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/detect.py b/platform/iphone/detect.py index 9cb52d4561..b92b64e9f1 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -3,185 +3,187 @@ import sys def is_active(): - return True + return True + def get_name(): - return "iOS" + return "iOS" + def can_build(): - import sys - import os - if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"): - return True + import sys + import os + if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"): + return True + + return False - return False def get_opts(): - return [ - ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'), - ('IPHONEPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), - ('IPHONESDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${IPHONEPLATFORM}.platform/Developer/SDKs/${IPHONEPLATFORM}.sdk/'), - ('game_center', 'Support for game center', 'yes'), - ('store_kit', 'Support for in-app store', 'yes'), - ('icloud', 'Support for iCloud', 'yes'), - ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'), - ('ios_appirater', 'Enable Appirater', 'no'), - ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'), - ('ios_triple', 'Triple for ios toolchain', ''), - ('ios_sim', 'Build simulator binary', 'no'), - ] + return [ + ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'), + ('IPHONEPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), + ('IPHONESDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${IPHONEPLATFORM}.platform/Developer/SDKs/${IPHONEPLATFORM}.sdk/'), + ('game_center', 'Support for game center', 'yes'), + ('store_kit', 'Support for in-app store', 'yes'), + ('icloud', 'Support for iCloud', 'yes'), + ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'), + ('ios_appirater', 'Enable Appirater', 'no'), + ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'), + ('ios_triple', 'Triple for ios toolchain', ''), + ('ios_sim', 'Build simulator binary', 'no'), + ] -def get_flags(): - return [ - ('tools', 'no'), - ('webp', 'yes'), - ('openssl','builtin'), #use builtin openssl - ] +def get_flags(): + return [ + ('tools', 'no'), + ] def configure(env): - env.Append(CPPPATH=['#platform/iphone']) - - env['ENV']['PATH'] = env['IPHONEPATH']+"/Developer/usr/bin/:"+env['ENV']['PATH'] - - env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang' - env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++' - env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar' - env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib' - - import string - if (env["ios_sim"]=="yes" or env["arch"] == "x86"): # i386, simulator - env["arch"]="x86" - env["bits"]="32" - env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') - elif (env["arch"]=="arm64"): # arm64 - env["bits"] = "64" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK') - env.Append(CPPFLAGS=['-DNEED_LONG_INT']) - env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) - else: # armv7 - env["arch"] = "arm" - env["bits"] = "32" - env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK') - - if (env["arch"]=="x86"): - env['IPHONEPLATFORM'] = 'iPhoneSimulator' - env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3', - '-isysroot', '$IPHONESDK', - #'-mmacosx-version-min=10.6', - '-Xlinker', - '-objc_abi_version', - '-Xlinker', '2', - '-framework', 'AudioToolbox', - '-framework', 'AVFoundation', - '-framework', 'CoreAudio', - '-framework', 'CoreGraphics', - '-framework', 'CoreMedia', - '-framework', 'Foundation', - '-framework', 'Security', - '-framework', 'UIKit', - '-framework', 'MediaPlayer', - '-framework', 'OpenGLES', - '-framework', 'QuartzCore', - '-framework', 'SystemConfiguration', - '-F$IPHONESDK', - ]) - elif (env["arch"]=="arm64"): - env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', - '-isysroot', '$IPHONESDK', - #'-stdlib=libc++', - '-framework', 'Foundation', - '-framework', 'UIKit', - '-framework', 'CoreGraphics', - '-framework', 'OpenGLES', - '-framework', 'QuartzCore', - '-framework', 'CoreAudio', - '-framework', 'AudioToolbox', - '-framework', 'SystemConfiguration', - '-framework', 'Security', - #'-framework', 'AdSupport', - '-framework', 'MediaPlayer', - '-framework', 'AVFoundation', - '-framework', 'CoreMedia', - ]) - else: - env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', - '-isysroot', '$IPHONESDK', - '-framework', 'Foundation', - '-framework', 'UIKit', - '-framework', 'CoreGraphics', - '-framework', 'OpenGLES', - '-framework', 'QuartzCore', - '-framework', 'CoreAudio', - '-framework', 'AudioToolbox', - '-framework', 'SystemConfiguration', - '-framework', 'Security', - #'-framework', 'AdSupport', - '-framework', 'MediaPlayer', - '-framework', 'AVFoundation', - '-framework', 'CoreMedia', - ]) - - if env['game_center'] == 'yes': - env.Append(CPPFLAGS=['-fblocks', '-DGAME_CENTER_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'GameKit']) - - if env['store_kit'] == 'yes': - env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'StoreKit']) - - if env['icloud'] == 'yes': - env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) - - env.Append(CPPPATH = ['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers']) - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1','-Wall', '-gdwarf-2']) # removed -ffast-math - env.Append(LINKFLAGS=['-O3']) # - - elif env["target"] == "release_debug": - env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED']) - env.Append(LINKFLAGS=['-Os']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) - - elif (env["target"]=="profile"): - - env.Append(CCFLAGS=['-g','-pg', '-Os']) - env.Append(LINKFLAGS=['-pg']) - - if (env["ios_sim"]=="yes"): #TODO: Check if needed? - env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6' - env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' - env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT']) - - if(env["opus"]=="yes"): - env.opus_fixed_point="yes" - if env["arch"]=="x86": - pass - elif(env["arch"]=="arm64"): - env.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) - else: - env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) - - if env['ios_exceptions'] == 'yes': - env.Append(CPPFLAGS=['-fexceptions']) - else: - env.Append(CPPFLAGS=['-fno-exceptions']) - #env['neon_enabled']=True - env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc' - - import methods - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append(CPPPATH=['#platform/iphone']) + + env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] + + env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang' + env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++' + env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar' + env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib' + + import string + if (env["ios_sim"] == "yes" or env["arch"] == "x86"): # i386, simulator + env["arch"] = "x86" + env["bits"] = "32" + env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') + elif (env["arch"] == "arm64"): # arm64 + env["bits"] = "64" + env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK') + env.Append(CPPFLAGS=['-DNEED_LONG_INT']) + env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) + else: # armv7 + env["arch"] = "arm" + env["bits"] = "32" + env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK') + + if (env["arch"] == "x86"): + env['IPHONEPLATFORM'] = 'iPhoneSimulator' + env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3', + '-isysroot', '$IPHONESDK', + #'-mmacosx-version-min=10.6', + '-Xlinker', + '-objc_abi_version', + '-Xlinker', '2', + '-framework', 'AudioToolbox', + '-framework', 'AVFoundation', + '-framework', 'CoreAudio', + '-framework', 'CoreGraphics', + '-framework', 'CoreMedia', + '-framework', 'Foundation', + '-framework', 'Security', + '-framework', 'UIKit', + '-framework', 'MediaPlayer', + '-framework', 'OpenGLES', + '-framework', 'QuartzCore', + '-framework', 'SystemConfiguration', + '-F$IPHONESDK', + ]) + elif (env["arch"] == "arm64"): + env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', + '-isysroot', '$IPHONESDK', + #'-stdlib=libc++', + '-framework', 'Foundation', + '-framework', 'UIKit', + '-framework', 'CoreGraphics', + '-framework', 'OpenGLES', + '-framework', 'QuartzCore', + '-framework', 'CoreAudio', + '-framework', 'AudioToolbox', + '-framework', 'SystemConfiguration', + '-framework', 'Security', + #'-framework', 'AdSupport', + '-framework', 'MediaPlayer', + '-framework', 'AVFoundation', + '-framework', 'CoreMedia', + ]) + else: + env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1', + '-isysroot', '$IPHONESDK', + '-framework', 'Foundation', + '-framework', 'UIKit', + '-framework', 'CoreGraphics', + '-framework', 'OpenGLES', + '-framework', 'QuartzCore', + '-framework', 'CoreAudio', + '-framework', 'AudioToolbox', + '-framework', 'SystemConfiguration', + '-framework', 'Security', + #'-framework', 'AdSupport', + '-framework', 'MediaPlayer', + '-framework', 'AVFoundation', + '-framework', 'CoreMedia', + ]) + + if env['game_center'] == 'yes': + env.Append(CPPFLAGS=['-fblocks', '-DGAME_CENTER_ENABLED']) + env.Append(LINKFLAGS=['-framework', 'GameKit']) + + if env['store_kit'] == 'yes': + env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) + env.Append(LINKFLAGS=['-framework', 'StoreKit']) + + if env['icloud'] == 'yes': + env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) + + env.Append(CPPPATH=['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers']) + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-gdwarf-2']) # removed -ffast-math + env.Append(LINKFLAGS=['-O3']) + + elif env["target"] == "release_debug": + env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-DDEBUG_ENABLED']) + env.Append(LINKFLAGS=['-Os']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) + + elif (env["target"] == "profile"): + + env.Append(CCFLAGS=['-g', '-pg', '-Os']) + env.Append(LINKFLAGS=['-pg']) + + if (env["ios_sim"] == "yes"): # TODO: Check if needed? + env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6' + env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' + env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT']) + + # TODO: Move that to opus module's config + if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + env.opus_fixed_point = "yes" + if env["arch"] == "x86": + pass + elif(env["arch"] == "arm64"): + env.Append(CFLAGS=["-DOPUS_ARM64_OPT"]) + else: + env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) + + if env['ios_exceptions'] == 'yes': + env.Append(CPPFLAGS=['-fexceptions']) + else: + env.Append(CPPFLAGS=['-fno-exceptions']) + # env['neon_enabled']=True + env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc' + + import methods + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h index 62477a0da2..abbeaaf86f 100644 --- a/platform/iphone/game_center.h +++ b/platform/iphone/game_center.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class GameCenter : public Object { - OBJ_TYPE(GameCenter, Object); + GDCLASS(GameCenter, Object); static GameCenter* instance; static void _bind_methods(); diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index a5b90514da..03ee327d65 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -48,18 +48,18 @@ extern "C" { GameCenter* GameCenter::instance = NULL; void GameCenter::_bind_methods() { - ObjectTypeDB::bind_method(_MD("connect"),&GameCenter::connect); - ObjectTypeDB::bind_method(_MD("is_connected"),&GameCenter::is_connected); - - ObjectTypeDB::bind_method(_MD("post_score"),&GameCenter::post_score); - ObjectTypeDB::bind_method(_MD("award_achievement"),&GameCenter::award_achievement); - ObjectTypeDB::bind_method(_MD("reset_achievements"),&GameCenter::reset_achievements); - ObjectTypeDB::bind_method(_MD("request_achievements"),&GameCenter::request_achievements); - ObjectTypeDB::bind_method(_MD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions); - ObjectTypeDB::bind_method(_MD("show_game_center"),&GameCenter::show_game_center); - - ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&GameCenter::get_pending_event_count); - ObjectTypeDB::bind_method(_MD("pop_pending_event"),&GameCenter::pop_pending_event); + ClassDB::bind_method(_MD("connect"),&GameCenter::connect); + ClassDB::bind_method(_MD("is_connected"),&GameCenter::is_connected); + + ClassDB::bind_method(_MD("post_score"),&GameCenter::post_score); + ClassDB::bind_method(_MD("award_achievement"),&GameCenter::award_achievement); + ClassDB::bind_method(_MD("reset_achievements"),&GameCenter::reset_achievements); + ClassDB::bind_method(_MD("request_achievements"),&GameCenter::request_achievements); + ClassDB::bind_method(_MD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions); + ClassDB::bind_method(_MD("show_game_center"),&GameCenter::show_game_center); + + ClassDB::bind_method(_MD("get_pending_event_count"),&GameCenter::get_pending_event_count); + ClassDB::bind_method(_MD("pop_pending_event"),&GameCenter::pop_pending_event); }; diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index 9c27c6a025..49e7810f08 100755 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 607352ab0b..d8ed930157 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp index 23261ceb02..0a67566398 100755 --- a/platform/iphone/globals/global_defaults.cpp +++ b/platform/iphone/globals/global_defaults.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/globals/global_defaults.h b/platform/iphone/globals/global_defaults.h index 0f4bf64c9b..1432b74425 100644 --- a/platform/iphone/globals/global_defaults.h +++ b/platform/iphone/globals/global_defaults.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp index 2ecfe1545e..27804e5c03 100644 --- a/platform/iphone/godot_iphone.cpp +++ b/platform/iphone/godot_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/icloud.h b/platform/iphone/icloud.h index dcf3677c85..ba50c4be15 100644 --- a/platform/iphone/icloud.h +++ b/platform/iphone/icloud.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -36,7 +36,7 @@ class ICloud : public Object { - OBJ_TYPE(ICloud, Object); + GDCLASS(ICloud, Object); static ICloud* instance; static void _bind_methods(); diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm index 0b3efe41fc..de70bb7e14 100644 --- a/platform/iphone/icloud.mm +++ b/platform/iphone/icloud.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -44,14 +44,14 @@ extern "C" { ICloud* ICloud::instance = NULL; void ICloud::_bind_methods() { - ObjectTypeDB::bind_method(_MD("remove_key"),&ICloud::remove_key); - ObjectTypeDB::bind_method(_MD("set_key_values"),&ICloud::set_key_values); - ObjectTypeDB::bind_method(_MD("get_key_value"),&ICloud::get_key_value); - ObjectTypeDB::bind_method(_MD("synchronize_key_values"),&ICloud::synchronize_key_values); - ObjectTypeDB::bind_method(_MD("get_all_key_values"),&ICloud::get_all_key_values); - - ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&ICloud::get_pending_event_count); - ObjectTypeDB::bind_method(_MD("pop_pending_event"),&ICloud::pop_pending_event); + ClassDB::bind_method(_MD("remove_key"),&ICloud::remove_key); + ClassDB::bind_method(_MD("set_key_values"),&ICloud::set_key_values); + ClassDB::bind_method(_MD("get_key_value"),&ICloud::get_key_value); + ClassDB::bind_method(_MD("synchronize_key_values"),&ICloud::synchronize_key_values); + ClassDB::bind_method(_MD("get_all_key_values"),&ICloud::get_all_key_values); + + ClassDB::bind_method(_MD("get_pending_event_count"),&ICloud::get_pending_event_count); + ClassDB::bind_method(_MD("pop_pending_event"),&ICloud::pop_pending_event); }; int ICloud::get_pending_event_count() { diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h index bd4215231e..59a745c0f7 100644 --- a/platform/iphone/in_app_store.h +++ b/platform/iphone/in_app_store.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class InAppStore : public Object { - OBJ_TYPE(InAppStore, Object); + GDCLASS(InAppStore, Object); static InAppStore* instance; static void _bind_methods(); diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index a2efe2711b..49026ceb0a 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -66,13 +66,13 @@ NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary]; InAppStore* InAppStore::instance = NULL; void InAppStore::_bind_methods() { - ObjectTypeDB::bind_method(_MD("request_product_info"),&InAppStore::request_product_info); - ObjectTypeDB::bind_method(_MD("purchase"),&InAppStore::purchase); + ClassDB::bind_method(_MD("request_product_info"),&InAppStore::request_product_info); + ClassDB::bind_method(_MD("purchase"),&InAppStore::purchase); - ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&InAppStore::get_pending_event_count); - ObjectTypeDB::bind_method(_MD("pop_pending_event"),&InAppStore::pop_pending_event); - ObjectTypeDB::bind_method(_MD("finish_transaction"),&InAppStore::finish_transaction); - ObjectTypeDB::bind_method(_MD("set_auto_finish_transaction"),&InAppStore::set_auto_finish_transaction); + ClassDB::bind_method(_MD("get_pending_event_count"),&InAppStore::get_pending_event_count); + ClassDB::bind_method(_MD("pop_pending_event"),&InAppStore::pop_pending_event); + ClassDB::bind_method(_MD("finish_transaction"),&InAppStore::finish_transaction); + ClassDB::bind_method(_MD("set_auto_finish_transaction"),&InAppStore::set_auto_finish_transaction); }; @interface ProductsDelegate : NSObject<SKProductsRequestDelegate> { diff --git a/platform/iphone/ios.h b/platform/iphone/ios.h index 8861417284..345bf127f2 100644 --- a/platform/iphone/ios.h +++ b/platform/iphone/ios.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class iOS : public Object { - OBJ_TYPE(iOS, Object); + GDCLASS(iOS, Object); static void _bind_methods(); diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm index 949d3bcb27..a068d4aa31 100644 --- a/platform/iphone/ios.mm +++ b/platform/iphone/ios.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 @@ void iOS::_bind_methods() { - ObjectTypeDB::bind_method(_MD("get_rate_url","app_id"),&iOS::get_rate_url); + ClassDB::bind_method(_MD("get_rate_url","app_id"),&iOS::get_rate_url); }; String iOS::get_rate_url(int p_app_id) const { diff --git a/platform/iphone/main.m b/platform/iphone/main.m index ea46a69672..02a45737c5 100644 --- a/platform/iphone/main.m +++ b/platform/iphone/main.m @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 93496e8225..e4d99cc502 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 9f919940c0..331b20afbf 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/platform_config.h b/platform/iphone/platform_config.h index e40f670185..c8468f0152 100644 --- a/platform/iphone/platform_config.h +++ b/platform/iphone/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/platform_refcount.h b/platform/iphone/platform_refcount.h index 3bf8652b4a..d32fb4514c 100644 --- a/platform/iphone/platform_refcount.h +++ b/platform/iphone/platform_refcount.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp index 5478569a42..3654f6d2d6 100644 --- a/platform/iphone/rasterizer_iphone.cpp +++ b/platform/iphone/rasterizer_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -486,7 +486,7 @@ RID RasterizerIPhone::material_create() { return material_owner.make_rid( memnew( Material ) ); } -void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::FixedMaterialParam p_parameter, const Variant& p_value) { +void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::FixedSpatialMaterialParam p_parameter, const Variant& p_value) { Material *m=material_owner.get( p_material ); ERR_FAIL_COND(!m); @@ -494,7 +494,7 @@ void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::FixedMat m->parameters[p_parameter] = p_value; } -Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material,VS::FixedMaterialParam p_parameter) const { +Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material,VS::FixedSpatialMaterialParam p_parameter) const { Material *m=material_owner.get( p_material ); ERR_FAIL_COND_V(!m, Variant()); @@ -503,7 +503,7 @@ Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material,VS::FixedM return m->parameters[p_parameter]; } -void RasterizerIPhone::fixed_material_set_texture(RID p_material,VS::FixedMaterialParam p_parameter, RID p_texture) { +void RasterizerIPhone::fixed_material_set_texture(RID p_material,VS::FixedSpatialMaterialParam p_parameter, RID p_texture) { Material *m=material_owner.get( p_material ); ERR_FAIL_COND(!m); @@ -511,7 +511,7 @@ void RasterizerIPhone::fixed_material_set_texture(RID p_material,VS::FixedMateri m->textures[p_parameter] = p_texture; } -RID RasterizerIPhone::fixed_material_get_texture(RID p_material,VS::FixedMaterialParam p_parameter) const { +RID RasterizerIPhone::fixed_material_get_texture(RID p_material,VS::FixedSpatialMaterialParam p_parameter) const { Material *m=material_owner.get( p_material ); ERR_FAIL_COND_V(!m, RID()); @@ -535,7 +535,7 @@ VS::MaterialBlendMode RasterizerIPhone::fixed_material_get_detail_blend_mode(RID return m->detail_blend_mode; } -void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter, VS::FixedMaterialTexCoordMode p_mode) { +void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material,VS::FixedSpatialMaterialParam p_parameter, VS::FixedSpatialMaterialTexCoordMode p_mode) { Material *m=material_owner.get( p_material ); ERR_FAIL_COND(!m); @@ -543,7 +543,7 @@ void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material,VS::Fixed m->texcoord_mode[p_parameter] = p_mode; } -VS::FixedMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter) const { +VS::FixedSpatialMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoord_mode(RID p_material,VS::FixedSpatialMaterialParam p_parameter) const { Material *m=material_owner.get( p_material ); ERR_FAIL_COND_V(!m, VS::FIXED_MATERIAL_TEXCOORD_TEXGEN); @@ -552,7 +552,7 @@ VS::FixedMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoord_mode return m->texcoord_mode[p_parameter]; // for now } -void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material,VS::FixedMaterialTexGenMode p_mode) { +void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material,VS::FixedSpatialMaterialTexGenMode p_mode) { Material *m=material_owner.get( p_material ); ERR_FAIL_COND(!m); @@ -560,7 +560,7 @@ void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material,VS::FixedMa m->texgen_mode = p_mode; }; -VS::FixedMaterialTexGenMode RasterizerIPhone::fixed_material_get_texgen_mode(RID p_material) const { +VS::FixedSpatialMaterialTexGenMode RasterizerIPhone::fixed_material_get_texgen_mode(RID p_material) const { Material *m=material_owner.get( p_material ); ERR_FAIL_COND_V(!m, VS::FIXED_MATERIAL_TEXGEN_SPHERE); diff --git a/platform/iphone/rasterizer_iphone.h b/platform/iphone/rasterizer_iphone.h index fcbb339ab3..cec367e2fa 100644 --- a/platform/iphone/rasterizer_iphone.h +++ b/platform/iphone/rasterizer_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -100,11 +100,11 @@ class RasterizerIPhone : public Rasterizer { RID textures[VisualServer::FIXED_MATERIAL_PARAM_MAX]; Transform uv_transform; - VS::FixedMaterialTexCoordMode texcoord_mode[VisualServer::FIXED_MATERIAL_PARAM_MAX]; + VS::FixedSpatialMaterialTexCoordMode texcoord_mode[VisualServer::FIXED_MATERIAL_PARAM_MAX]; VS::MaterialBlendMode detail_blend_mode; - VS::FixedMaterialTexGenMode texgen_mode; + VS::FixedSpatialMaterialTexGenMode texgen_mode; Material() { @@ -624,20 +624,20 @@ public: virtual RID material_create(); - virtual void fixed_material_set_parameter(RID p_material, VS::FixedMaterialParam p_parameter, const Variant& p_value); - virtual Variant fixed_material_get_parameter(RID p_material,VS::FixedMaterialParam p_parameter) const; + virtual void fixed_material_set_parameter(RID p_material, VS::FixedSpatialMaterialParam p_parameter, const Variant& p_value); + virtual Variant fixed_material_get_parameter(RID p_material,VS::FixedSpatialMaterialParam p_parameter) const; - virtual void fixed_material_set_texture(RID p_material,VS::FixedMaterialParam p_parameter, RID p_texture); - virtual RID fixed_material_get_texture(RID p_material,VS::FixedMaterialParam p_parameter) const; + virtual void fixed_material_set_texture(RID p_material,VS::FixedSpatialMaterialParam p_parameter, RID p_texture); + virtual RID fixed_material_get_texture(RID p_material,VS::FixedSpatialMaterialParam p_parameter) const; virtual void fixed_material_set_detail_blend_mode(RID p_material,VS::MaterialBlendMode p_mode); virtual VS::MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const; - virtual void fixed_material_set_texgen_mode(RID p_material,VS::FixedMaterialTexGenMode p_mode); - virtual VS::FixedMaterialTexGenMode fixed_material_get_texgen_mode(RID p_material) const; + virtual void fixed_material_set_texgen_mode(RID p_material,VS::FixedSpatialMaterialTexGenMode p_mode); + virtual VS::FixedSpatialMaterialTexGenMode fixed_material_get_texgen_mode(RID p_material) const; - virtual void fixed_material_set_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter, VS::FixedMaterialTexCoordMode p_mode); - virtual VS::FixedMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter) const; + virtual void fixed_material_set_texcoord_mode(RID p_material,VS::FixedSpatialMaterialParam p_parameter, VS::FixedSpatialMaterialTexCoordMode p_mode); + virtual VS::FixedSpatialMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,VS::FixedSpatialMaterialParam p_parameter) const; virtual void fixed_material_set_uv_transform(RID p_material,const Transform& p_transform); virtual Transform fixed_material_get_uv_transform(RID p_material) const; diff --git a/platform/iphone/sem_iphone.cpp b/platform/iphone/sem_iphone.cpp index e9c54a002e..d8913feb5f 100644 --- a/platform/iphone/sem_iphone.cpp +++ b/platform/iphone/sem_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/sem_iphone.h b/platform/iphone/sem_iphone.h index bfeaf244e5..e00dd8f3dd 100644 --- a/platform/iphone/sem_iphone.h +++ b/platform/iphone/sem_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/view_controller.h b/platform/iphone/view_controller.h index 52c8ac9953..f919c06af2 100644 --- a/platform/iphone/view_controller.h +++ b/platform/iphone/view_controller.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/iphone/view_controller.mm b/platform/iphone/view_controller.mm index 647ded30a7..8b3dc7c984 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/SCsub b/platform/javascript/SCsub index fc70d45a04..5d5cd1590a 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -1,27 +1,37 @@ +#!/usr/bin/env python + Import('env') javascript_files = [ - "os_javascript.cpp", - "audio_driver_javascript.cpp", - "javascript_main.cpp", - "audio_server_javascript.cpp", - "javascript_eval.cpp" + "os_javascript.cpp", + "audio_driver_javascript.cpp", + "javascript_main.cpp", + "audio_server_javascript.cpp", + "javascript_eval.cpp" ] -#obj = env.SharedObject('godot_javascript.cpp') - env_javascript = env.Clone() if env['target'] == "profile": - env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED']) + env_javascript.Append(CPPFLAGS=['-DPROFILER_ENABLED']) -javascript_objects=[] +javascript_objects = [] for x in javascript_files: - javascript_objects.append( env_javascript.Object( x ) ) + javascript_objects.append(env_javascript.Object(x)) -env.Append(LINKFLAGS=["-s","EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) +env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) +env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) -prog = None +build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html") -#env_javascript.SharedLibrary("#platform/javascript/libgodot_javascript.so",[javascript_objects]) +def make_html_shell(target, source, env): + html_path = target[0].rstr() + assert html_path[:4] == 'bin/' + assert html_path[-5:] == '.html' + basename = html_path[4:-5] + with open(html_path, 'r+') as html_file: + fixed_html = html_file.read().replace('.html.mem', '.mem').replace(basename, '$GODOT_BASE') + html_file.seek(0) + html_file.truncate() + html_file.write(fixed_html) -env.Program('#bin/godot',javascript_objects,PROGSUFFIX=env["PROGSUFFIX"]+".html") +env.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file")) diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index 1b949e64f9..579cbaed3c 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h index c674a8566e..528b45569d 100644 --- a/platform/javascript/audio_driver_javascript.h +++ b/platform/javascript/audio_driver_javascript.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index 71a7e77266..fec553df04 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index e27192cd93..47aadf6bc6 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class AudioServerJavascript : public AudioServer { - OBJ_TYPE(AudioServerJavascript,AudioServer); + GDCLASS(AudioServerJavascript,AudioServer); enum { INTERNAL_BUFFER_SIZE=4096, diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index aeff5a1a34..2cb6874000 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -2,114 +2,114 @@ import os import sys import string + def is_active(): - return True + return True + def get_name(): - return "JavaScript" + return "JavaScript" + def can_build(): - import os - if (not os.environ.has_key("EMSCRIPTEN_ROOT")): - return False - return True + import os + if (not os.environ.has_key("EMSCRIPTEN_ROOT")): + return False + return True -def get_opts(): - return [ - ['compress','Compress JS Executable','no'], - ['javascript_eval','Enable JavaScript eval interface','yes'] - ] +def get_opts(): -def get_flags(): + return [ + ['wasm', 'Compile to WebAssembly', 'no'], + ['javascript_eval', 'Enable JavaScript eval interface', 'yes'], + ] - return [ - ('lua', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('theora', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('musepack', 'no'), - ('squirrel', 'no'), - ('squish', 'no'), - ('speex', 'no'), - ('old_scenes', 'no'), - ('etc1', 'no'), -# ('default_gui_theme', 'no'), - #('builtin_zlib', 'no'), - ] +def get_flags(): + return [ + ('tools', 'no'), + ('module_etc1_enabled', 'no'), + ('module_mpc_enabled', 'no'), + ('module_theora_enabled', 'no'), + ] def configure(env): - env['ENV'] = os.environ; - env.use_windows_spawn_fix('javascript') + env['ENV'] = os.environ + env.use_windows_spawn_fix('javascript') - env.Append(CPPPATH=['#platform/javascript']) + env.Append(CPPPATH=['#platform/javascript']) - em_path=os.environ["EMSCRIPTEN_ROOT"] + em_path = os.environ["EMSCRIPTEN_ROOT"] - env['ENV']['PATH'] = em_path+":"+env['ENV']['PATH'] - - env['CC'] = em_path+'/emcc' - env['CXX'] = em_path+'/emcc' - #env['AR'] = em_path+"/emar" - env['AR'] = em_path+"/emcc" - env['ARFLAGS'] = "-o" + env['ENV']['PATH'] = em_path + ":" + env['ENV']['PATH'] + env['CC'] = em_path + '/emcc' + env['CXX'] = em_path + '/emcc' + #env['AR'] = em_path+"/emar" + env['AR'] = em_path + "/emcc" + env['ARFLAGS'] = "-o" # env['RANLIB'] = em_path+"/emranlib" - env['RANLIB'] = em_path + "/emcc" - env['OBJSUFFIX'] = '.bc' - env['LIBSUFFIX'] = '.bc' - env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" - env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" + env['RANLIB'] = em_path + "/emcc" + env['OBJSUFFIX'] = '.bc' + env['LIBSUFFIX'] = '.bc' + env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" + env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" # env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) # env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") - if (env["target"]=="release"): - env.Append(CCFLAGS=['-O2']) - elif (env["target"]=="release_debug"): - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) - #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) - - if(env["opus"]=="yes"): - env.opus_fixed_point="yes" - - env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) - env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL','-DMPC_FIXED_POINT','-DTYPED_METHOD_BIND','-DNO_THREADS']) - env.Append(CPPFLAGS=['-DGLES2_ENABLED']) - env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) - env.Append(CPPFLAGS=['-s','ASM_JS=1']) - env.Append(CPPFLAGS=['-s','FULL_ES2=1']) + if (env["target"] == "release"): + env.Append(CCFLAGS=['-O2']) + elif (env["target"] == "release_debug"): + env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + elif (env["target"] == "debug"): + env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) + #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) + + # TODO: Move that to opus module's config + if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): + env.opus_fixed_point = "yes" + + # These flags help keep the file size down + env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) + env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) + env.Append(CPPFLAGS=['-DGLES2_ENABLED']) + env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) + env.Append(CPPFLAGS=['-s', 'FULL_ES2=1']) # env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) - if env['javascript_eval'] == 'yes': - env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) - - if (env["compress"]=="yes"): - lzma_binpath = em_path+"/third_party/lzma.js/lzma-native" - lzma_decoder = em_path+"/third_party/lzma.js/lzma-decoder.js" - lzma_dec = "LZMA.decompress" - env.Append(LINKFLAGS=['--compression',lzma_binpath+","+lzma_decoder+","+lzma_dec]) - - env.Append(LINKFLAGS=['-s','ASM_JS=1']) - env.Append(LINKFLAGS=['-O2']) - #env.Append(LINKFLAGS=['-g4']) - - #print "CCCOM is:", env.subst('$CCCOM') - #print "P: ", env['p'], " Platofrm: ", env['platform'] - - import methods - - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - 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') } ) + if env['wasm'] == 'yes': + env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) + # Maximum memory size is baked into the WebAssembly binary during + # compilation, so we need to enable memory growth to allow setting + # TOTAL_MEMORY at runtime. The value set at runtime must be higher than + # what is set during compilation, check TOTAL_MEMORY in Emscripten's + # src/settings.js for the default. + env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) + env["PROGSUFFIX"] += ".webassembly" + else: + env.Append(CPPFLAGS=['-s', 'ASM_JS=1']) + env.Append(LINKFLAGS=['-s', 'ASM_JS=1']) + env.Append(LINKFLAGS=['--separate-asm']) + + if env['javascript_eval'] == 'yes': + env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) + + env.Append(LINKFLAGS=['-O2']) + # env.Append(LINKFLAGS=['-g4']) + + # print "CCCOM is:", env.subst('$CCCOM') + # print "P: ", env['p'], " Platofrm: ", env['platform'] + + import methods + + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + 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') } ) diff --git a/platform/javascript/dom_keys.h b/platform/javascript/dom_keys.h index 282b632e93..5ef212ce4a 100644 --- a/platform/javascript/dom_keys.h +++ b/platform/javascript/dom_keys.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/export/export.cpp b/platform/javascript/export/export.cpp index de57d770c4..77aab98e0c 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -40,7 +40,7 @@ #include "string.h" class EditorExportPlatformJavaScript : public EditorExportPlatform { - OBJ_TYPE( EditorExportPlatformJavaScript,EditorExportPlatform ); + GDCLASS( EditorExportPlatformJavaScript,EditorExportPlatform ); String custom_release_package; String custom_debug_package; @@ -180,9 +180,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St String current_line = lines[i]; current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024)); - current_line = current_line.replace("$GODOT_FS",p_name+"fs.js"); - current_line = current_line.replace("$GODOT_MEM",p_name+".mem"); - current_line = current_line.replace("$GODOT_JS",p_name+".js"); + current_line = current_line.replace("$GODOT_BASE",p_name); current_line = current_line.replace("$GODOT_CANVAS_WIDTH",Globals::get_singleton()->get("display/width")); current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",Globals::get_singleton()->get("display/height")); current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) Globals::get_singleton()->get("application/name")); @@ -195,8 +193,8 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St } CharString cs = strnew.utf8(); - p_html.resize(cs.size()); - for(int i=9;i<cs.size();i++) { + p_html.resize(cs.length()); + for(int i=9;i<cs.length();i++) { p_html[i]=cs[i]; } } @@ -319,16 +317,24 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool } if (file=="godot.js") { - //_fix_godot(data); file=p_path.get_file().basename()+".js"; } + if (file=="godot.asm.js") { + + file=p_path.get_file().basename()+".asm.js"; + } + if (file=="godot.mem") { - //_fix_godot(data); file=p_path.get_file().basename()+".mem"; } + if (file=="godot.wasm") { + + file=p_path.get_file().basename()+".wasm"; + } + String dst = p_path.get_base_dir().plus_file(file); FileAccess *f=FileAccess::open(dst,FileAccess::WRITE); if (!f) { diff --git a/platform/javascript/export/export.h b/platform/javascript/export/export.h index 2105141e58..59c0a67e6d 100644 --- a/platform/javascript/export/export.h +++ b/platform/javascript/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/godot_shell.html b/platform/javascript/godot_shell.html new file mode 100644 index 0000000000..3170d2bb9e --- /dev/null +++ b/platform/javascript/godot_shell.html @@ -0,0 +1,357 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> +<head> + <meta charset="utf-8" /> + <title>$GODOT_HEAD_TITLE</title> + $GODOT_HEAD_INCLUDE + <style type="text/css"> + body { + margin: 0; + border: 0 none; + padding: 0; + text-align: center; + background-color: black; + font-family: $GODOT_STYLE_FONT_FAMILY; + } + + + /* Godot Engine default theme style + * ================================ */ + + .godot { + color: #e0e0e0; + background-color: #3b3943; + background-image: linear-gradient(to bottom, #403e48, #35333c); + border: 1px solid #45434e; + box-shadow: 0 0 1px 1px #2f2d35; + } + + button.godot { + font-family: $GODOT_STYLE_FONT_FAMILY; /* override user agent style */ + padding: 1px 5px; + background-color: #37353f; + background-image: linear-gradient(to bottom, #413e49, #3a3842); + border: 1px solid #514f5d; + border-radius: 1px; + box-shadow: 0 0 1px 1px #2a2930; + } + + button.godot:hover { + color: #f0f0f0; + background-color: #44414e; + background-image: linear-gradient(to bottom, #494652, #423f4c); + border: 1px solid #5a5667; + box-shadow: 0 0 1px 1px #26252b; + } + + button.godot:active { + color: #fff; + background-color: #3e3b46; + background-image: linear-gradient(to bottom, #36343d, #413e49); + border: 1px solid #4f4c59; + box-shadow: 0 0 1px 1px #26252b; + } + + button.godot:disabled { + color: rgba(230, 230, 230, 0.2); + background-color: #3d3d3d; + background-image: linear-gradient(to bottom, #434343, #393939); + border: 1px solid #474747; + box-shadow: 0 0 1px 1px #2d2b33; + } + + + /* Canvas / wrapper + * ================ */ + + #container { + display: inline-block; /* scale with canvas */ + vertical-align: top; /* prevent extra height */ + position: relative; /* root for absolutely positioned overlay */ + margin: 0; + border: 0 none; + padding: 0; + background-color: #111; + } + + #canvas { + display: block; + margin: 0 auto; + /* canvas must have border and padding set to zero to + * calculate cursor coordinates correctly */ + border: 0 none; + padding: 0; + } + + + /* Status display + * ============== */ + + #status-container { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + display: flex; + justify-content: center; + align-items: center; + /* don't consume click events - make children visible explicitly */ + visibility: hidden; + } + + #status { + visibility: visible; + padding: 4px 6px; + } + + + /* On-hover controls + * ================= */ + + #controls { + visibility: hidden; + opacity: 0.0; + transition: opacity 500ms ease-in-out 200ms; + position: absolute; + right: 16px; + top: 16px; + padding: 3px 5px; + font-size: small; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + } + + #container:hover > #controls { + opacity: 1.0; + transition: opacity 60ms ease-in-out; + } + + #controls > button, + #controls > label { + vertical-align: middle; + margin-left: 2px; + margin-right: 2px; + } + + #controls > label > input[type="checkbox"] { + /* override user agent style */ + margin-left: 0; + } + + label > input { + vertical-align: middle; + } + + #display-output { display: none; } + + + /* Debug output + * ============ */ + + #output { + display: none; + margin: 6px auto; + border: 2px groove grey; + padding: 4px; + outline: none; + text-align: left; + white-space: pre-wrap; + font-size: small; + color: #eee; + background-color: black; + font-family: "Lucida Console", Monaco, monospace; + } + + + /* Export style include + * ==================== */ + + $GODOT_STYLE_INCLUDE + </style> +</head> +<body> + <div id="container"> + <canvas id="canvas" width="$GODOT_CANVAS_WIDTH" height="$GODOT_CANVAS_HEIGHT" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();"> + HTML5 canvas appears to be unsupported in the current browser.<br />Please try updating or use a different browser. + </canvas> + <div id="status-container"> + <span id="status" class="godot" onclick="this.style.visibility='hidden';">Loading page...</span> + </div> + <div id="controls" class="godot"> + <label id="display-output"><input id="output-toggle" type="checkbox" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />display output</label> + <!-- hidden until implemented + <label><input id="lock-cursor" type="checkbox" autocomplete="off" />lock cursor</label> + <label><input id="resize-canvas" type="checkbox" autocomplete="off" />resize canvas</label> + --> + <button id="fullscreen" class="godot" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.goFullscreen();">fullscreen</button> + </div> + </div> + <!-- Firefox adds extra space to textarea, but shouldn't matter too much https://bugzilla.mozilla.org/show_bug.cgi?id=33654 --> + <textarea id="output" rows="10" cols="100" readonly="readonly" style="resize:none"></textarea> + + <script type="text/javascript">//<![CDATA[ + var Presentation = (function() { + var statusElement = document.getElementById("status"); + var outputElement = document.getElementById("output"); + var doneLoading = false; + + function onLoaded() { + doneLoading = true; + var fullscreenButtonElement = document.getElementById("fullscreen"); + fullscreenButtonElement.disabled = false; + } + + var presentation = { + statusElement: statusElement, + outputElement: outputElement, + setOutputVisible: function setOutputVisible(visible) { + outputElement.style.display = (visible?"block":"none"); + }, + setStatusVisible: function setStatusVisible(visible) { + statusElement.style.visibility = (visible?"visible":"hidden"); + }, + setStatus: function setStatus(text) { + if (!text || text.length === 0) { + Presentation.setStatusVisible(false); + onLoaded(); + } else { + Presentation.setStatusVisible(true); + statusElement.innerHTML = text; + } + }, + goFullscreen: function goFullscreen() { + if (doneLoading) Module.requestFullScreen(false, false); + } + }; + + if ($GODOT_CONTROLS_ENABLED) { // controls enabled + (function() { + var controlsElement = document.getElementById("controls"); + controlsElement.style.visibility="visible"; + })(); + } + + if ($GODOT_DEBUG_ENABLED) { // debugging enabled + (function() { + var outputToggleLabel = document.getElementById("display-output"); + var outputToggle = document.getElementById("output-toggle"); + + outputElement.value = ""; // clear browser cache + outputElement.style.display = "block"; + outputToggle.checked = true; + outputToggleLabel.style.display = "inline"; + + presentation.print = function print(text) { + if (outputElement.value.length !== 0) + outputElement.value += "\n"; + outputElement.value += text; + outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom + }; + })(); + } + + return presentation; + })(); + + // Emscripten interface + var Module = (function() { + var print = (function() { + if (typeof Presentation.print === "function") { + return function print(text) { + if (arguments.length > 1) + text = Array.prototype.slice.call(arguments).join(" "); + console.log(text); + Presentation.print(text); + }; + } else { + return function print(text) { + if (arguments.length > 1) + text = Array.prototype.slice.call(arguments).join(" "); + console.log(text); + }; + } + })(); + + var canvas = (function() { + var canvasElement = document.getElementById("canvas"); + + // As a default initial behavior, pop up an alert when WebGL context is lost. To make your + // application robust, you may want to override this behavior before shipping! + // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 + canvasElement.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false); + + return canvasElement; + })(); + + var setStatus = (function() { + if (typeof Presentation.setStatus === "function") + return function setStatus(text) { + if (!Module.setStatus.last) + Module.setStatus.last = { time: Date.now(), text: "" }; + if (text === Module.setStatus.text) + return; + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + var now = Date.now(); + if (m) { + if (now - Date.now() < 30) // if this is a progress update, skip it if too soon + return; + text = m[1]; + } + Presentation.setStatus(text); + }; + else + return function setStatus(text) { + if (!Module.setStatus.last) + Module.setStatus.last = { time: Date.now(), text: "" }; + if (text === Module.setStatus.text) + return; + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + var now = Date.now(); + if (m) { + if (now - Date.now() < 30) // if this is a progress update, skip it if too soon + return; + text = m[1]; + } + }; + })(); + + return { + TOTAL_MEMORY: 268435456, + preRun: [], + postRun: [], + print: print, + printErr: function printErr(text) { + if (arguments.length > 1) + text = Array.prototype.slice.call(arguments).join(" "); + if (0) { // XXX disabled for safety `if (typeof dump == "function")` + dump(text + "\n"); // fast, straight to the real console + } else { + console.error(text); + } + }, + canvas: canvas, + setStatus: setStatus, + totalDependencies: 0, + monitorRunDependencies: function monitorRunDependencies(left) { + this.totalDependencies = Math.max(this.totalDependencies, left); + Module.setStatus(left ? "Preparing... (" + (this.totalDependencies-left) + "/" + this.totalDependencies + ")" : "All downloads complete."); + } + }; + })(); + + Presentation.setStatus("Downloading..."); + + window.onerror = function(event) { + // TODO: do not warn on ok events like simulating an infinite loop or exitStatus + Module.setStatus("Exception thrown, see JavaScript console"); + Module.setStatus = function(text) { + if (text) Module.printErr("[post-exception status] " + text); + }; + }; + //]]></script> + <script type="text/javascript" src="$GODOT_BASEfs.js"></script> + {{{ SCRIPT }}} +</body> +</html> diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index e642300bda..7bbe0ae99b 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/javascript/javascript_eval.h b/platform/javascript/javascript_eval.h index e5f6268076..679224d519 100644 --- a/platform/javascript/javascript_eval.h +++ b/platform/javascript/javascript_eval.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class JavaScript : public Object { private: - OBJ_TYPE( JavaScript, Object ); + GDCLASS( JavaScript, Object ); static JavaScript *singleton; diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index d9342cfe10..4c47594810 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -66,11 +66,12 @@ static void _glut_mouse_button(int button, int state, int x, int y) { if (ev.mouse_button.button_index<4) { if (ev.mouse_button.pressed) { - _mouse_button_mask|=1<<ev.mouse_button.button_index; + _mouse_button_mask |= 1 << (ev.mouse_button.button_index-1); } else { - _mouse_button_mask&=~(1<<ev.mouse_button.button_index); + _mouse_button_mask &= ~(1 << (ev.mouse_button.button_index-1)); } } + ev.mouse_button.button_mask=_mouse_button_mask; uint32_t m = glutGetModifiers(); ev.mouse_button.mod.alt=(m&GLUT_ACTIVE_ALT)!=0; @@ -79,6 +80,11 @@ static void _glut_mouse_button(int button, int state, int x, int y) { os->push_input(ev); + if (ev.mouse_button.button_index==BUTTON_WHEEL_UP || ev.mouse_button.button_index==BUTTON_WHEEL_DOWN) { + // GLUT doesn't send release events for mouse wheel, so send manually + ev.mouse_button.pressed=false; + os->push_input(ev); + } } @@ -148,7 +154,7 @@ int main(int argc, char *argv[]) { /* Initialize the window */ printf("let it go!\n"); glutInit(&argc, argv); - os = new OS_JavaScript(_gfx_init,NULL,NULL,NULL,NULL); + os = new OS_JavaScript(_gfx_init,NULL,NULL); #if 0 char *args[]={"-test","gui","-v",NULL}; Error err = Main::setup("apk",3,args); @@ -162,7 +168,6 @@ int main(int argc, char *argv[]) { glutMouseFunc(_glut_mouse_button); glutMotionFunc(_glut_mouse_motion); - glutMotionFunc(_glut_mouse_motion); glutPassiveMotionFunc(_glut_mouse_motion); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index e802a7e9cb..f1b67021f0 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -37,6 +37,7 @@ #include "main/main.h" #include "core/globals.h" +#include "stdlib.h" #include "emscripten.h" #include "dom_keys.h" @@ -77,6 +78,59 @@ void OS_JavaScript::set_opengl_extensions(const char* p_gl_extensions) { gl_extensions=p_gl_extensions; } +static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent *ui_event, void *user_data) { + + ERR_FAIL_COND_V(event_type!=EMSCRIPTEN_EVENT_RESIZE, false); + + OS_JavaScript* os = static_cast<OS_JavaScript*>(user_data); + + // the order in which _browser_resize_callback and + // _fullscreen_change_callback are called is browser-dependent, + // so try adjusting for fullscreen in both + if (os->is_window_fullscreen() || os->is_window_maximized()) { + + OS::VideoMode vm = os->get_video_mode(); + vm.width = ui_event->windowInnerWidth; + vm.height = ui_event->windowInnerHeight; + os->set_video_mode(vm); + emscripten_set_canvas_size(ui_event->windowInnerWidth, ui_event->windowInnerHeight); + } + return false; +} + +static Size2 _windowed_size; + +static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) { + + ERR_FAIL_COND_V(event_type!=EMSCRIPTEN_EVENT_FULLSCREENCHANGE, false); + + OS_JavaScript* os = static_cast<OS_JavaScript*>(user_data); + String id = String::utf8(event->id); + + // empty id is canvas + if (id.empty() || id=="canvas") { + + OS::VideoMode vm = os->get_video_mode(); + // this event property is the only reliable information on + // browser fullscreen state + vm.fullscreen = event->isFullscreen; + + if (event->isFullscreen) { + vm.width = event->screenWidth; + vm.height = event->screenHeight; + os->set_video_mode(vm); + emscripten_set_canvas_size(vm.width, vm.height); + } + else { + os->set_video_mode(vm); + if (!os->is_window_maximized()) { + os->set_window_size(_windowed_size); + } + } + } + return false; +} + static InputEvent _setup_key_event(const EmscriptenKeyboardEvent *emscripten_event) { InputEvent ev; @@ -89,7 +143,9 @@ static InputEvent _setup_key_event(const EmscriptenKeyboardEvent *emscripten_eve ev.key.scancode = dom2godot_scancode(emscripten_event->keyCode); String unicode = String::utf8(emscripten_event->key); + // check if empty or multi-character (e.g. `CapsLock`) if (unicode.length()!=1) { + // might be empty as well, but better than nonsense unicode = String::utf8(emscripten_event->charValue); } if (unicode.length()==1) { @@ -151,7 +207,30 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int if (gfx_init_func) gfx_init_func(gfx_init_ud,use_gl2,p_desired.width,p_desired.height,p_desired.fullscreen); - default_videomode=p_desired; + // nothing to do here, can't fulfil fullscreen request due to + // browser security, window size is already set from HTML + video_mode=p_desired; + video_mode.fullscreen=false; + _windowed_size=get_window_size(); + + // find locale, emscripten only sets "C" + char locale_ptr[16]; + EM_ASM_({ + var locale = ""; + if (Module.locale) { + // best case: server-side script reads Accept-Language early and + // defines the locale to be read here + locale = Module.locale; + } else { + // no luck, use what the JS engine can tell us + // if this turns out not compatible enough, add tests for + // browserLanguage, systemLanguage and userLanguage + locale = navigator.languages ? navigator.languages[0] : navigator.language; + } + locale = locale.split('.')[0]; + stringToUTF8(locale, $0, 16); + }, locale_ptr); + setenv("LANG", locale_ptr, true); print_line("Init Audio"); @@ -210,26 +289,23 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int input = memnew( InputDefault ); - EMSCRIPTEN_RESULT result = emscripten_set_keydown_callback(NULL, this , true, &_keydown_callback); - if (result!=EMSCRIPTEN_RESULT_SUCCESS) { - ERR_PRINTS( "Error while setting Emscripten keydown callback: Code " + itos(result) ); - } - result = emscripten_set_keypress_callback(NULL, this, true, &_keypress_callback); - if (result!=EMSCRIPTEN_RESULT_SUCCESS) { - ERR_PRINTS( "Error while setting Emscripten keypress callback: Code " + itos(result) ); - } - result = emscripten_set_keyup_callback(NULL, this, true, &_keyup_callback); - if (result!=EMSCRIPTEN_RESULT_SUCCESS) { - ERR_PRINTS( "Error while setting Emscripten keyup callback: Code " + itos(result) ); - } - result = emscripten_set_gamepadconnected_callback(NULL, true, &joy_callback_func); - if (result!=EMSCRIPTEN_RESULT_SUCCESS) { - ERR_PRINTS( "Error while setting Emscripten gamepadconnected callback: Code " + itos(result) ); - } - result = emscripten_set_gamepaddisconnected_callback(NULL, true, &joy_callback_func); - if (result!=EMSCRIPTEN_RESULT_SUCCESS) { - ERR_PRINTS( "Error while setting Emscripten gamepaddisconnected callback: Code " + itos(result) ); - } +#define EM_CHECK(ev) if (result!=EMSCRIPTEN_RESULT_SUCCESS)\ + ERR_PRINTS("Error while setting " #ev " callback: Code " + itos(result)) +#define SET_EM_CALLBACK(ev, cb) result = emscripten_set_##ev##_callback(NULL, this, true, &cb); EM_CHECK(ev) +#define SET_EM_CALLBACK_NODATA(ev, cb) result = emscripten_set_##ev##_callback(NULL, true, &cb); EM_CHECK(ev) + + EMSCRIPTEN_RESULT result; + SET_EM_CALLBACK(keydown, _keydown_callback) + SET_EM_CALLBACK(keypress, _keypress_callback) + SET_EM_CALLBACK(keyup, _keyup_callback) + SET_EM_CALLBACK(resize, _browser_resize_callback) + SET_EM_CALLBACK(fullscreenchange, _fullscreen_change_callback) + SET_EM_CALLBACK_NODATA(gamepadconnected, joy_callback_func) + SET_EM_CALLBACK_NODATA(gamepaddisconnected, joy_callback_func) + +#undef SET_EM_CALLBACK_NODATA +#undef SET_EM_CALLBACK +#undef EM_CHECK #ifdef JAVASCRIPT_EVAL_ENABLED javascript_eval = memnew(JavaScript); @@ -254,32 +330,11 @@ void OS_JavaScript::finalize() { memdelete(input); } +void OS_JavaScript::alert(const String& p_alert,const String& p_title) { -void OS_JavaScript::vprint(const char* p_format, va_list p_list, bool p_stderr) { - - if (p_stderr) { - - vfprintf(stderr,p_format,p_list); - fflush(stderr); - } else { - - vprintf(p_format,p_list); - fflush(stdout); - } -} - -void OS_JavaScript::print(const char *p_format, ... ) { - - va_list argp; - va_start(argp, p_format); - vprintf(p_format, argp ); - va_end(argp); - -} - -void OS_JavaScript::alert(const String& p_alert) { - - print("ALERT: %s\n",p_alert.utf8().get_data()); + EM_ASM_({ + window.alert(UTF8ToString($0)); + }, p_alert.utf8().get_data()); } @@ -298,17 +353,22 @@ bool OS_JavaScript::is_mouse_grab_enabled() const { //*sigh* technology has evolved so much since i was a kid.. return false; } + Point2 OS_JavaScript::get_mouse_pos() const { - return Point2(); + return input->get_mouse_pos(); } + int OS_JavaScript::get_mouse_button_state() const { - return 0; + return last_button_mask; } -void OS_JavaScript::set_window_title(const String& p_title) { +void OS_JavaScript::set_window_title(const String& p_title) { + EM_ASM_({ + document.title = UTF8ToString($0); + }, p_title.utf8().get_data()); } //interesting byt not yet @@ -317,22 +377,92 @@ void OS_JavaScript::set_window_title(const String& p_title) { void OS_JavaScript::set_video_mode(const VideoMode& p_video_mode,int p_screen) { - + video_mode = p_video_mode; } OS::VideoMode OS_JavaScript::get_video_mode(int p_screen) const { - return default_videomode; + return video_mode; +} + +Size2 OS_JavaScript::get_screen_size(int p_screen) const { + + ERR_FAIL_COND_V(p_screen!=0, Size2()); + + EmscriptenFullscreenChangeEvent ev; + EMSCRIPTEN_RESULT result = emscripten_get_fullscreen_status(&ev); + ERR_FAIL_COND_V(result!=EMSCRIPTEN_RESULT_SUCCESS, Size2()); + return Size2(ev.screenWidth, ev.screenHeight); +} + +void OS_JavaScript::set_window_size(const Size2 p_size) { + + window_maximized = false; + if (is_window_fullscreen()) { + set_window_fullscreen(false); + } + _windowed_size = p_size; + video_mode.width = p_size.x; + video_mode.height = p_size.y; + emscripten_set_canvas_size(p_size.x, p_size.y); } Size2 OS_JavaScript::get_window_size() const { - return Vector2(default_videomode.width,default_videomode.height); + int canvas[3]; + emscripten_get_canvas_size(canvas, canvas+1, canvas+2); + return Size2(canvas[0], canvas[1]); +} + +void OS_JavaScript::set_window_maximized(bool p_enabled) { + + window_maximized = p_enabled; + if (p_enabled) { + + if (is_window_fullscreen()) { + // _browser_resize callback will set canvas size + set_window_fullscreen(false); + } + else { + video_mode.width = EM_ASM_INT_V(return window.innerWidth); + video_mode.height = EM_ASM_INT_V(return window.innerHeight); + emscripten_set_canvas_size(video_mode.width, video_mode.height); + } + } + else { + set_window_size(_windowed_size); + } +} + +void OS_JavaScript::set_window_fullscreen(bool p_enable) { + + if (p_enable==is_window_fullscreen()) { + return; + } + + // only requesting changes here, if successful, canvas is resized in + // _browser_resize_callback or _fullscreen_change_callback + EMSCRIPTEN_RESULT result; + if (p_enable) { + EM_ASM(Module.requestFullscreen(false, false);); + } + else { + result = emscripten_exit_fullscreen(); + if (result!=EMSCRIPTEN_RESULT_SUCCESS) { + ERR_PRINTS("Failed to exit fullscreen: Code " + itos(result)); + } + } +} + +bool OS_JavaScript::is_window_fullscreen() const { + + return video_mode.fullscreen; } void OS_JavaScript::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { - p_list->push_back(default_videomode); + Size2 screen = get_screen_size(); + p_list->push_back(OS::VideoMode(screen.width, screen.height, true)); } String OS_JavaScript::get_name() { @@ -423,6 +553,9 @@ void OS_JavaScript::push_input(const InputEvent& p_ev) { if (ev.type==InputEvent::MOUSE_MOTION) { input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y)); } + else if (ev.type==InputEvent::MOUSE_BUTTON) { + last_button_mask = ev.mouse_button.button_mask; + } input->parse_input_event(p_ev); } @@ -649,40 +782,26 @@ void OS_JavaScript::main_loop_request_quit() { main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); } -void OS_JavaScript::set_display_size(Size2 p_size) { - - default_videomode.width=p_size.x; - default_videomode.height=p_size.y; -} - void OS_JavaScript::reload_gfx() { if (gfx_init_func) - gfx_init_func(gfx_init_ud,use_gl2,default_videomode.width,default_videomode.height,default_videomode.fullscreen); + gfx_init_func(gfx_init_ud,use_gl2,video_mode.width,video_mode.height,video_mode.fullscreen); if (rasterizer) rasterizer->reload_vram(); } Error OS_JavaScript::shell_open(String p_uri) { - - if (open_uri_func) - return open_uri_func(p_uri)?ERR_CANT_OPEN:OK; - return ERR_UNAVAILABLE; -}; + EM_ASM_({ + window.open(UTF8ToString($0), '_blank'); + }, p_uri.utf8().get_data()); + return OK; +} String OS_JavaScript::get_resource_dir() const { return "/"; //javascript has it's own filesystem for resources inside the APK } -String OS_JavaScript::get_locale() const { - - if (get_locale_func) - return get_locale_func(); - return OS_Unix::get_locale(); -} - - String OS_JavaScript::get_data_dir() const { //if (get_data_dir_func) @@ -691,6 +810,10 @@ String OS_JavaScript::get_data_dir() const { //return Globals::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir"); }; +String OS_JavaScript::get_executable_path() const { + + return String(); +} void OS_JavaScript::_close_notification_funcs(const String& p_file,int p_flags) { @@ -757,24 +880,18 @@ String OS_JavaScript::get_joy_guid(int p_device) const { return input->get_joy_guid_remapped(p_device); } -OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func) { - - - default_videomode.width=800; - default_videomode.height=600; - default_videomode.fullscreen=true; - default_videomode.resizable=false; +OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func) { gfx_init_func=p_gfx_init_func; gfx_init_ud=p_gfx_init_ud; + last_button_mask=0; main_loop=NULL; last_id=1; gl_extensions=NULL; rasterizer=NULL; + window_maximized=false; - open_uri_func=p_open_uri_func; get_data_dir_func=p_get_data_dir_func; - get_locale_func=p_get_locale_func; FileAccessUnix::close_notification_func=_close_notification_funcs; time_to_save_sync=-1; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 5b7904805b..4cdc88f4f9 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -45,9 +45,7 @@ #include "javascript_eval.h" typedef void (*GFXInitFunc)(void *ud,bool gl2,int w, int h, bool fs); -typedef int (*OpenURIFunc)(const String&); typedef String (*GetDataDirFunc)(); -typedef String (*GetLocaleFunc)(); class OS_JavaScript : public OS_Unix { public: @@ -61,6 +59,7 @@ private: Vector<TouchPos> touch; Point2 last_mouse; + int last_button_mask; unsigned int last_id; GFXInitFunc gfx_init_func; void*gfx_init_ud; @@ -82,12 +81,11 @@ private: const char* gl_extensions; InputDefault *input; - VideoMode default_videomode; + bool window_maximized; + VideoMode video_mode; MainLoop * main_loop; - OpenURIFunc open_uri_func; GetDataDirFunc get_data_dir_func; - GetLocaleFunc get_locale_func; #ifdef JAVASCRIPT_EVAL_ENABLED JavaScript* javascript_eval; @@ -121,9 +119,12 @@ public: //static OS* get_singleton(); - virtual void vprint(const char* p_format, va_list p_list, bool p_stderr=false); - virtual void print(const char *p_format, ... ); - virtual void alert(const String& p_alert); + virtual void print_error(const char* p_function, const char* p_file, int p_line, const char *p_code, const char* p_rationale, ErrorType p_type) { + + OS::print_error(p_function, p_file, p_line, p_code, p_rationale, p_type); + } + + virtual void alert(const String& p_alert,const String& p_title="ALERT!"); virtual void set_mouse_show(bool p_show); @@ -140,7 +141,15 @@ public: 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; + virtual Size2 get_screen_size(int p_screen=0) const; + + virtual void set_window_size(const Size2); virtual Size2 get_window_size() const; + virtual void set_window_maximized(bool p_enabled); + virtual bool is_window_maximized() const { return window_maximized; } + virtual void set_window_fullscreen(bool p_enable); + virtual bool is_window_fullscreen() const; + virtual String get_name(); virtual MainLoop *get_main_loop() const; @@ -158,14 +167,13 @@ public: virtual bool has_touchscreen_ui_hint() const; void set_opengl_extensions(const char* p_gl_extensions); - void set_display_size(Size2 p_size); void reload_gfx(); virtual Error shell_open(String p_uri); virtual String get_data_dir() const; + String get_executable_path() const; virtual String get_resource_dir() const; - virtual String get_locale() const; void process_accelerometer(const Vector3& p_accelerometer); void process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points); @@ -175,7 +183,7 @@ public: virtual String get_joy_guid(int p_device) const; bool joy_connection_changed(int p_type, const EmscriptenGamepadEvent *p_event); - OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func); + OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func); ~OS_JavaScript(); }; diff --git a/platform/javascript/platform_config.h b/platform/javascript/platform_config.h index 143f16c1fa..cdef185ff0 100644 --- a/platform/javascript/platform_config.h +++ b/platform/javascript/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/SCsub b/platform/osx/SCsub index 4169795519..c8e0e17612 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -1,13 +1,15 @@ +#!/usr/bin/env python + Import('env') files = [ - 'os_osx.mm', - 'godot_main_osx.mm', - 'audio_driver_osx.cpp', - 'sem_osx.cpp', -# 'context_gl_osx.cpp', - 'dir_access_osx.mm', - 'joystick_osx.cpp', - ] + 'os_osx.mm', + 'godot_main_osx.mm', + 'audio_driver_osx.cpp', + 'sem_osx.cpp', + # 'context_gl_osx.cpp', + 'dir_access_osx.mm', + 'joystick_osx.cpp', +] -env.Program('#bin/godot',files) +env.Program('#bin/godot', files) diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp index d9d91b22fb..87901f6ec4 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 92893c64dc..19b396de57 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 df1c14c643..d0819bbfb6 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 565a0ee02a..6a02aa23d1 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 01ea09fa21..ccd86177ab 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -4,109 +4,99 @@ import sys def is_active(): - return True + return True + def get_name(): - return "OSX" + return "OSX" + def can_build(): - if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")): - return True + if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")): + return True + return False - return False def get_opts(): - return [ - ('force_64_bits','Force 64 bits binary','no'), - ('osxcross_sdk','OSXCross SDK version','darwin14'), + return [ + ('force_64_bits', 'Force 64 bits binary', 'no'), + ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), - ] + ] -def get_flags(): - return [ - ('legacygl', 'yes'), - ('builtin_zlib', 'no'), - ('glew', 'yes'), - ] +def get_flags(): + return [ + ] def configure(env): - env.Append(CPPPATH=['#platform/osx']) - - if (env["bits"]=="default"): - env["bits"]="32" - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer','-ftree-vectorize','-msse2']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-g3', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - - - - 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']) - elif (env["bits"]=="32"): - env.Append(CCFLAGS=['-arch', 'i386']) - env.Append(LINKFLAGS=['-arch', 'i386']) - else: - env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64']) - env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64']) - else: - #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']) - - - env.Append(CPPFLAGS=["-DAPPLE_STYLE_KEYS"]) - env.Append(CPPFLAGS=['-DUNIX_ENABLED','-DGLES2_ENABLED','-DOSX_ENABLED']) - env.Append(LIBS=['pthread']) - #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4']) - #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk']) - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit','-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) - - if (env["CXX"]=="clang++"): - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env["CC"]="clang" - env["LD"]="clang++" - if (env["colored"]=="yes"): - if sys.stdout.isatty(): - env.Append(CPPFLAGS=["-fcolor-diagnostics"]) - - import methods - - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - 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 + env.Append(CPPPATH=['#platform/osx']) + + if (env["bits"] == "default"): + env["bits"] = "32" + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g3', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + 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']) + elif (env["bits"] == "32"): + env.Append(CCFLAGS=['-arch', 'i386']) + env.Append(LINKFLAGS=['-arch', 'i386']) + else: + env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64']) + env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64']) + else: + # 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(CPPFLAGS=["-DAPPLE_STYLE_KEYS"]) + env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DOSX_ENABLED']) + env.Append(CPPFLAGS=["-mmacosx-version-min=10.9"]) + env.Append(LIBS=['pthread']) + #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4']) + #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk']) + env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) + env.Append(LINKFLAGS=["-mmacosx-version-min=10.9"]) + + if (env["CXX"] == "clang++"): + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env["CC"] = "clang" + env["LD"] = "clang++" + + import methods + + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + 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_libtheora_opt_gcc"] = True diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h index d20eee1e2e..c30d380dd3 100644 --- a/platform/osx/dir_access_osx.h +++ b/platform/osx/dir_access_osx.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/dir_access_osx.mm b/platform/osx/dir_access_osx.mm index 5615858262..476da2635e 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/export/export.cpp b/platform/osx/export/export.cpp index c55bf0eadb..d8298eee73 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -43,7 +43,7 @@ class EditorExportPlatformOSX : public EditorExportPlatform { - OBJ_TYPE( EditorExportPlatformOSX,EditorExportPlatform ); + GDCLASS( EditorExportPlatformOSX,EditorExportPlatform ); String custom_release_package; String custom_debug_package; diff --git a/platform/osx/export/export.h b/platform/osx/export/export.h index 8e0b83b457..98e63ff48e 100644 --- a/platform/osx/export/export.h +++ b/platform/osx/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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_main_osx.mm b/platform/osx/godot_main_osx.mm index 7beb5248b4..8eedd7f6fc 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 de363d8483..b6f2b06f26 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 02a1382b1a..2296fb016f 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/joystick_osx.cpp b/platform/osx/joystick_osx.cpp index ffb6ac326b..740c349fe1 100644 --- a/platform/osx/joystick_osx.cpp +++ b/platform/osx/joystick_osx.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/joystick_osx.h b/platform/osx/joystick_osx.h index 38a4e3b1d3..ec745fe5d1 100644 --- a/platform/osx/joystick_osx.h +++ b/platform/osx/joystick_osx.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 e23ae49a35..8c4eb28ff0 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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.mm b/platform/osx/os_osx.mm index 5a5ddccd60..d5b870bc7d 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/platform_config.h b/platform/osx/platform_config.h index dc04e9b4f1..e3c1ee031c 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -28,6 +28,6 @@ /*************************************************************************/ #include <alloca.h> -#define GLES2_INCLUDE_H "gl_context/GL/glew.h" -#define GLES3_INCLUDE_H "gl_context/GL/glew.h" +#define GLES2_INCLUDE_H "GL/glew.h" +#define GLES3_INCLUDE_H "GL/glew.h" #define PTHREAD_RENAME_SELF diff --git a/platform/osx/sem_osx.cpp b/platform/osx/sem_osx.cpp index 6909097fec..ca710d8b1e 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 ec5ddac4e0..da2fac434c 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-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/server/SCsub b/platform/server/SCsub index 3dda6b4395..30195bb908 100644 --- a/platform/server/SCsub +++ b/platform/server/SCsub @@ -1,8 +1,10 @@ +#!/usr/bin/env python + Import('env') -common_server=[\ - "os_server.cpp",\ +common_server = [\ + "os_server.cpp",\ ] -env.Program('#bin/godot_server',['godot_server.cpp']+common_server) +env.Program('#bin/godot_server', ['godot_server.cpp'] + common_server) diff --git a/platform/server/detect.py b/platform/server/detect.py index e6fab2043b..8bc85f342d 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -4,77 +4,116 @@ import sys def is_active(): - return True + return True + def get_name(): - return "Server" + return "Server" def can_build(): - if (os.name!="posix"): - return False + if (os.name != "posix"): + return False + + return True # enabled - return True # enabled def get_opts(): - return [ - ('use_llvm','Use llvm compiler','no'), - ('force_32_bits','Force 32 bits binary','no') - ] + return [ + ('use_llvm', 'Use llvm compiler', 'no'), + ('force_32_bits', 'Force 32 bits binary', 'no') + ] -def get_flags(): - return [ - ('builtin_zlib', 'no'), - ] +def get_flags(): + return [ + ] def configure(env): - env.Append(CPPPATH=['#platform/server']) - if (env["use_llvm"]=="yes"): - env["CC"]="clang" - env["CXX"]="clang++" - env["LD"]="clang++" - if (env["colored"]=="yes"): - if sys.stdout.isatty(): - env.Append(CXXFLAGS=["-fcolor-diagnostics"]) + env.Append(CPPPATH=['#platform/server']) + if (env["use_llvm"] == "yes"): + env["CC"] = "clang" + env["CXX"] = "clang++" + env["LD"] = "clang++" + + is64 = sys.maxsize > 2**32 + + if (env["bits"] == "default"): + if (is64): + env["bits"] = "64" + else: + env["bits"] = "32" + + # if (env["tools"]=="no"): + # #no tools suffix + # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] + # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + + # Shared libraries, when requested + + if (env['builtin_openssl'] == 'no'): + env.ParseConfig('pkg-config openssl --cflags --libs') - is64=sys.maxsize > 2**32 + if (env['builtin_libwebp'] == 'no'): + env.ParseConfig('pkg-config libwebp --cflags --libs') - if (env["bits"]=="default"): - if (is64): - env["bits"]="64" - else: - env["bits"]="32" + if (env['builtin_freetype'] == 'no'): + env.ParseConfig('pkg-config freetype2 --cflags --libs') + if (env['builtin_libpng'] == 'no'): + env.ParseConfig('pkg-config libpng --cflags --libs') - #if (env["tools"]=="no"): - # #no tools suffix - # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] - # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] + if (env['builtin_enet'] == 'no'): + env.ParseConfig('pkg-config libenet --cflags --libs') + if (env['builtin_squish'] == 'no' and env["tools"] == "yes"): + env.ParseConfig('pkg-config libsquish --cflags --libs') - if (env["target"]=="release"): + # Sound and video libraries + # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer']) + if (env['builtin_libtheora'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system libtheora + env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora + env.ParseConfig('pkg-config theora theoradec --cflags --libs') - elif (env["target"]=="release_debug"): + if (env['builtin_libvpx'] == 'no'): + env.ParseConfig('pkg-config vpx --cflags --libs') - env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) + if (env['builtin_libvorbis'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system libvorbis + env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') - elif (env["target"]=="debug"): + if (env['builtin_opus'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system opus + env.ParseConfig('pkg-config opus opusfile --cflags --libs') - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + if (env['builtin_libogg'] == 'no'): + env.ParseConfig('pkg-config ogg --cflags --libs') - env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED']) - env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD! - if (env["CXX"]=="clang++"): - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env["CC"]="clang" - env["LD"]="clang++" + env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED']) + env.Append(LIBS=['pthread', 'z']) # TODO detect linux/BSD! + if (env["CXX"] == "clang++"): + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env["CC"] = "clang" + env["LD"] = "clang++" diff --git a/platform/server/godot_server.cpp b/platform/server/godot_server.cpp index 1c55c03bd7..37e73d663d 100644 --- a/platform/server/godot_server.cpp +++ b/platform/server/godot_server.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/server/os_server.cpp b/platform/server/os_server.cpp index cb00fdaac8..e35ad1adf8 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/server/os_server.h b/platform/server/os_server.h index ed5111d831..6aa1b9e14b 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/server/platform_config.h b/platform/server/platform_config.h index 143f16c1fa..cdef185ff0 100644 --- a/platform/server/platform_config.h +++ b/platform/server/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/uwp/SCsub b/platform/uwp/SCsub new file mode 100644 index 0000000000..430d4ef9e7 --- /dev/null +++ b/platform/uwp/SCsub @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +Import('env') + +files = [ + 'thread_uwp.cpp', + '#platform/windows/tcp_server_winsock.cpp', + '#platform/windows/packet_peer_udp_winsock.cpp', + '#platform/windows/stream_peer_winsock.cpp', + '#platform/windows/key_mapping_win.cpp', + 'joystick_uwp.cpp', + 'gl_context_egl.cpp', + 'app.cpp', + 'os_uwp.cpp', +] + +if "build_angle" in env and env["build_angle"]: + cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None)) + +prog = env.Program('#bin/godot', files) + +if "build_angle" in env and env["build_angle"]: + env.Depends(prog, [cmd]) diff --git a/platform/winrt/app.cpp b/platform/uwp/app.cpp index c2b7ba0641..0bae148c6b 100644 --- a/platform/winrt/app.cpp +++ b/platform/uwp/app.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -53,7 +53,7 @@ using namespace Windows::System; using namespace Windows::System::Threading::Core; using namespace Microsoft::WRL; -using namespace GodotWinRT; +using namespace GodotUWP; // Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels. inline float ConvertDipsToPixels(float dips, float dpi) @@ -63,7 +63,7 @@ inline float ConvertDipsToPixels(float dips, float dpi) } // Implementation of the IFrameworkViewSource interface, necessary to run our app. -ref class GodotWinrtViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource +ref class GodotUWPViewSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource { public: virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() @@ -76,7 +76,7 @@ public: [Platform::MTAThread] int main(Platform::Array<Platform::String^>^) { - auto godotApplicationSource = ref new GodotWinrtViewSource(); + auto godotApplicationSource = ref new GodotUWPViewSource(); CoreApplication::Run(godotApplicationSource); return 0; } @@ -105,7 +105,7 @@ void App::Initialize(CoreApplicationView^ applicationView) // Information about the Suspending and Resuming event handlers can be found here: // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx - os = new OSWinrt; + os = new OSUWP; } @@ -157,7 +157,7 @@ void App::SetWindow(CoreWindow^ p_window) unsigned int argc; char** argv = get_command_line(&argc); - Main::setup("winrt", argc, argv, false); + Main::setup("uwp", argc, argv, false); // The CoreWindow has been created, so EGL can be initialized. ContextEGL* context = memnew(ContextEGL(window)); @@ -431,7 +431,7 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) { void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windows::UI::Core::KeyEventArgs^ key_args, Windows::UI::Core::CharacterReceivedEventArgs^ char_args) { - OSWinrt::KeyEvent ke; + OSUWP::KeyEvent ke; InputModifierState mod; mod.meta = false; @@ -445,14 +445,14 @@ void App::key_event(Windows::UI::Core::CoreWindow^ sender, bool p_pressed, Windo if (key_args != nullptr) { - ke.type = OSWinrt::KeyEvent::MessageType::KEY_EVENT_MESSAGE; + ke.type = OSUWP::KeyEvent::MessageType::KEY_EVENT_MESSAGE; ke.unicode = 0; ke.scancode = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey); ke.echo = (!p_pressed && !key_args->KeyStatus.IsKeyReleased) || (p_pressed && key_args->KeyStatus.WasKeyDown); } else { - ke.type = OSWinrt::KeyEvent::MessageType::CHAR_EVENT_MESSAGE; + ke.type = OSUWP::KeyEvent::MessageType::CHAR_EVENT_MESSAGE; ke.unicode = char_args->KeyCode; ke.scancode = 0; ke.echo = (!p_pressed && !char_args->KeyStatus.IsKeyReleased) || (p_pressed && char_args->KeyStatus.WasKeyDown); diff --git a/platform/winrt/app.h b/platform/uwp/app.h index 652ec86e1f..6df9c5699e 100644 --- a/platform/winrt/app.h +++ b/platform/uwp/app.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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,10 +32,10 @@ #include <wrl.h> -#include "os_winrt.h" +#include "os_uwp.h" #include "GLES2/gl2.h" -namespace GodotWinRT +namespace GodotUWP { ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView { @@ -97,7 +97,7 @@ namespace GodotWinRT EGLSurface mEglSurface; CoreWindow^ window; - OSWinrt* os; + OSUWP* os; int last_touch_x[32]; // 20 fingers, index 31 reserved for the mouse int last_touch_y[32]; diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py new file mode 100644 index 0000000000..6eb4ca9caa --- /dev/null +++ b/platform/uwp/detect.py @@ -0,0 +1,166 @@ +import os + +import sys +import string +import methods + + +def is_active(): + return True + + +def get_name(): + return "UWP" + + +def can_build(): + if (os.name == "nt"): + # building natively on windows! + if (os.getenv("VSINSTALLDIR")): + + if (os.getenv("ANGLE_SRC_PATH") == None): + return False + + return True + return False + + +def get_opts(): + return [] + + +def get_flags(): + + return [ + ('tools', 'no'), + ('xaudio2', 'yes'), + ] + + +def configure(env): + + if(env["bits"] != "default"): + print "Error: bits argument is disabled for MSVC" + print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" + + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=uwp) and SCons will attempt to detect what MSVC compiler" + + " will be executed and inform you.") + sys.exit() + + arch = "" + env['ENV'] = os.environ + + # ANGLE + angle_root = os.getenv("ANGLE_SRC_PATH") + env.Append(CPPPATH=[angle_root + '/include']) + jobs = str(env.GetOption("num_jobs")) + angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform=" + + if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): + env["build_angle"] = True + + if os.getenv('Platform') == "ARM": + + print "Compiled program architecture will be an ARM executable. (forcing bits=32)." + + arch = "arm" + env["bits"] = "32" + env.Append(LINKFLAGS=['/MACHINE:ARM']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm']) + + angle_build_cmd += "ARM" + + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) + + else: + + compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + + if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + env["bits"] = "64" + print "Compiled program architecture will be a x64 executable (forcing bits=64)." + elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"): + env["bits"] = "32" + print "Compiled program architecture will be a x86 executable. (forcing bits=32)." + else: + print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + env["bits"] = "32" + + if (env["bits"] == "32"): + arch = "x86" + + angle_build_cmd += "Win32" + + env.Append(CPPFLAGS=['/DPNG_ABORT=abort']) + env.Append(LINKFLAGS=['/MACHINE:X86']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store']) + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib']) + + else: + arch = "x64" + + angle_build_cmd += "x64" + + env.Append(LINKFLAGS=['/MACHINE:X64']) + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64']) + env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib']) + + env.Append(CPPPATH=['#platform/uwp', '#drivers/windows']) + env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"']) + env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32']) + env.Append(CPPFLAGS=['/FU', os.environ['VCINSTALLDIR'] + 'lib/store/references/platform.winmd']) + env.Append(CPPFLAGS=['/AI', os.environ['VCINSTALLDIR'] + 'lib/store/references']) + + env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references']) + + if (env["target"] == "release"): + + env.Append(CPPFLAGS=['/O2', '/GL']) + env.Append(CPPFLAGS=['/MD']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['/O2', '/Zi', '/DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['/MD']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['/Zi', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED']) + env.Append(CPPFLAGS=['/MDd']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + env.Append(LINKFLAGS=['/DEBUG']) + + env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo')) + env.Append(CXXFLAGS=string.split('/ZW /FS')) + env.Append(CCFLAGS=['/AI', os.environ['VCINSTALLDIR'] + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral']) + + env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"] + env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"] + env["LIBSUFFIX"] = "." + arch + env["LIBSUFFIX"] + + env.Append(CCFLAGS=['/DUWP_ENABLED']) + env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) + env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) + + env.Append(CCFLAGS=['/DGLES2_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED']) + + LIBS = [ + 'WindowsApp', + 'mincore', + 'libANGLE', + 'libEGL', + 'libGLESv2', + ] + env.Append(LINKFLAGS=[p + ".lib" for p in LIBS]) + + # Incremental linking fix + env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] + env['BUILDERS']['Program'] = methods.precious_program + + env.Append(BUILDERS={'ANGLE': env.Builder(action=angle_build_cmd)}) + + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_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.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/winrt/export/export.cpp b/platform/uwp/export/export.cpp index eca9f09de6..186c509ca5 100644 --- a/platform/winrt/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -71,7 +71,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "object.h" #include "tools/editor/editor_import_export.h" #include "tools/editor/editor_node.h" -#include "platform/winrt/logo.h" +#include "platform/uwp/logo.h" #include "os/file_access.h" #include "io/zip.h" #include "io/unzip.h" @@ -432,9 +432,9 @@ public: ~AppxPackager(); }; -class EditorExportPlatformWinrt : public EditorExportPlatform { +class EditorExportPlatformUWP : public EditorExportPlatform { - OBJ_TYPE(EditorExportPlatformWinrt, EditorExportPlatform); + GDCLASS(EditorExportPlatformUWP, EditorExportPlatform); Ref<ImageTexture> logo; @@ -528,8 +528,8 @@ public: virtual Error export_project(const String& p_path, bool p_debug, int p_flags = 0); - EditorExportPlatformWinrt(); - ~EditorExportPlatformWinrt(); + EditorExportPlatformUWP(); + ~EditorExportPlatformUWP(); }; @@ -1452,7 +1452,7 @@ Error AppxPackager::sign(const CertFile & p_cert, const AppxDigests & digests, P //////////////////////////////////////////////////////////////////// -bool EditorExportPlatformWinrt::_valid_resource_name(const String &p_name) const { +bool EditorExportPlatformUWP::_valid_resource_name(const String &p_name) const { if (p_name.empty()) return false; if (p_name.ends_with(".")) return false; @@ -1472,7 +1472,7 @@ bool EditorExportPlatformWinrt::_valid_resource_name(const String &p_name) const return true; } -bool EditorExportPlatformWinrt::_valid_guid(const String & p_guid) const { +bool EditorExportPlatformUWP::_valid_guid(const String & p_guid) const { Vector<String> parts = p_guid.split("-"); @@ -1485,7 +1485,7 @@ bool EditorExportPlatformWinrt::_valid_guid(const String & p_guid) const { return true; } -bool EditorExportPlatformWinrt::_valid_bgcolor(const String & p_color) const { +bool EditorExportPlatformUWP::_valid_bgcolor(const String & p_color) const { if (p_color.empty()) return true; if (p_color.begins_with("#") && p_color.is_valid_html_color()) return true; @@ -1529,7 +1529,7 @@ bool EditorExportPlatformWinrt::_valid_bgcolor(const String & p_color) const { return false; } -bool EditorExportPlatformWinrt::_valid_image(const Ref<ImageTexture> p_image, int p_width, int p_height) const { +bool EditorExportPlatformUWP::_valid_image(const Ref<ImageTexture> p_image, int p_width, int p_height) const { if (!p_image.is_valid()) return false; @@ -1553,7 +1553,7 @@ bool EditorExportPlatformWinrt::_valid_image(const Ref<ImageTexture> p_image, in return valid_w && valid_h; } -Vector<uint8_t> EditorExportPlatformWinrt::_fix_manifest(const Vector<uint8_t> &p_template, bool p_give_internet) const { +Vector<uint8_t> EditorExportPlatformUWP::_fix_manifest(const Vector<uint8_t> &p_template, bool p_give_internet) const { String result = String::utf8((const char*)p_template.ptr(), p_template.size()); @@ -1659,7 +1659,7 @@ Vector<uint8_t> EditorExportPlatformWinrt::_fix_manifest(const Vector<uint8_t> & return r_ret; } -Vector<uint8_t> EditorExportPlatformWinrt::_get_image_data(const String & p_path) { +Vector<uint8_t> EditorExportPlatformUWP::_get_image_data(const String & p_path) { Vector<uint8_t> data; Ref<ImageTexture> ref; @@ -1741,7 +1741,7 @@ Vector<uint8_t> EditorExportPlatformWinrt::_get_image_data(const String & p_path return data; } -Error EditorExportPlatformWinrt::save_appx_file(void * p_userdata, const String & p_path, const Vector<uint8_t>& p_data, int p_file, int p_total) { +Error EditorExportPlatformUWP::save_appx_file(void * p_userdata, const String & p_path, const Vector<uint8_t>& p_data, int p_file, int p_total) { AppxPackager *packager = (AppxPackager*)p_userdata; String dst_path = p_path.replace_first("res://", "game/"); @@ -1751,7 +1751,7 @@ Error EditorExportPlatformWinrt::save_appx_file(void * p_userdata, const String return OK; } -bool EditorExportPlatformWinrt::_should_compress_asset(const String & p_path, const Vector<uint8_t>& p_data) { +bool EditorExportPlatformUWP::_should_compress_asset(const String & p_path, const Vector<uint8_t>& p_data) { /* TODO: This was copied verbatim from Android export. It should be * refactored to the parent class and also be used for .zip export. @@ -1800,7 +1800,7 @@ bool EditorExportPlatformWinrt::_should_compress_asset(const String & p_path, co return true; } -bool EditorExportPlatformWinrt::_set(const StringName& p_name, const Variant& p_value) { +bool EditorExportPlatformUWP::_set(const StringName& p_name, const Variant& p_value) { String n = p_name; @@ -1906,7 +1906,7 @@ bool EditorExportPlatformWinrt::_set(const StringName& p_name, const Variant& p_ return true; } -bool EditorExportPlatformWinrt::_get(const StringName& p_name, Variant &r_ret) const { +bool EditorExportPlatformUWP::_get(const StringName& p_name, Variant &r_ret) const { String n = p_name; @@ -2002,7 +2002,7 @@ bool EditorExportPlatformWinrt::_get(const StringName& p_name, Variant &r_ret) c return true; } -void EditorExportPlatformWinrt::_get_property_list(List<PropertyInfo>* p_list) const { +void EditorExportPlatformUWP::_get_property_list(List<PropertyInfo>* p_list) const { p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "appx")); p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "appx")); @@ -2071,14 +2071,14 @@ void EditorExportPlatformWinrt::_get_property_list(List<PropertyInfo>* p_list) c } -bool EditorExportPlatformWinrt::can_export(String * r_error) const { +bool EditorExportPlatformUWP::can_export(String * r_error) const { String err; bool valid = true; - if (!exists_export_template("winrt_x86_debug.zip") || !exists_export_template("winrt_x86_release.zip") - || !exists_export_template("winrt_arm_debug.zip") || !exists_export_template("winrt_arm_release.zip") - || !exists_export_template("winrt_x64_debug.zip") || !exists_export_template("winrt_x64_release.zip")) { + if (!exists_export_template("uwp_x86_debug.zip") || !exists_export_template("uwp_x86_release.zip") + || !exists_export_template("uwp_arm_debug.zip") || !exists_export_template("uwp_arm_release.zip") + || !exists_export_template("uwp_x64_debug.zip") || !exists_export_template("uwp_x64_release.zip")) { valid = false; err += TTR("No export templates found.\nDownload and install export templates.") + "\n"; } @@ -2154,7 +2154,7 @@ bool EditorExportPlatformWinrt::can_export(String * r_error) const { return valid; } -Error EditorExportPlatformWinrt::export_project(const String & p_path, bool p_debug, int p_flags) { +Error EditorExportPlatformUWP::export_project(const String & p_path, bool p_debug, int p_flags) { String src_appx; @@ -2170,30 +2170,30 @@ Error EditorExportPlatformWinrt::export_project(const String & p_path, bool p_de if (p_debug) { switch (arch) { case X86: { - src_appx = find_export_template("winrt_x86_debug.zip", &err); + src_appx = find_export_template("uwp_x86_debug.zip", &err); break; } case X64: { - src_appx = find_export_template("winrt_x64_debug.zip", &err); + src_appx = find_export_template("uwp_x64_debug.zip", &err); break; } case ARM: { - src_appx = find_export_template("winrt_arm_debug.zip", &err); + src_appx = find_export_template("uwp_arm_debug.zip", &err); break; } } } else { switch (arch) { case X86: { - src_appx = find_export_template("winrt_x86_release.zip", &err); + src_appx = find_export_template("uwp_x86_release.zip", &err); break; } case X64: { - src_appx = find_export_template("winrt_x64_release.zip", &err); + src_appx = find_export_template("uwp_x64_release.zip", &err); break; } case ARM: { - src_appx = find_export_template("winrt_arm_release.zip", &err); + src_appx = find_export_template("uwp_arm_release.zip", &err); break; } } @@ -2337,9 +2337,9 @@ Error EditorExportPlatformWinrt::export_project(const String & p_path, bool p_de return OK; } -EditorExportPlatformWinrt::EditorExportPlatformWinrt() { +EditorExportPlatformUWP::EditorExportPlatformUWP() { - Image img(_winrt_logo); + Image img(_uwp_logo); logo = Ref<ImageTexture>(memnew(ImageTexture)); logo->create_from_image(img); @@ -2381,11 +2381,11 @@ EditorExportPlatformWinrt::EditorExportPlatformWinrt() { certificate_pass = ""; } -EditorExportPlatformWinrt::~EditorExportPlatformWinrt() {} +EditorExportPlatformUWP::~EditorExportPlatformUWP() {} -void register_winrt_exporter() { +void register_uwp_exporter() { - Ref<EditorExportPlatformWinrt> exporter = Ref<EditorExportPlatformWinrt>(memnew(EditorExportPlatformWinrt)); + Ref<EditorExportPlatformUWP> exporter = Ref<EditorExportPlatformUWP>(memnew(EditorExportPlatformUWP)); EditorImportExport::get_singleton()->add_export_platform(exporter); } diff --git a/platform/winrt/export/export.h b/platform/uwp/export/export.h index 278d6d23cd..2d6e02bb10 100644 --- a/platform/winrt/export/export.h +++ b/platform/uwp/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -26,4 +26,4 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -void register_winrt_exporter(); +void register_uwp_exporter(); diff --git a/platform/winrt/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp index f7b514b3c0..c9c03db8a1 100644 --- a/platform/winrt/gl_context_egl.cpp +++ b/platform/uwp/gl_context_egl.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/winrt/gl_context_egl.h b/platform/uwp/gl_context_egl.h index 8124c2903d..858eaa6d12 100644 --- a/platform/winrt/gl_context_egl.h +++ b/platform/uwp/gl_context_egl.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/winrt/joystick_winrt.cpp b/platform/uwp/joystick_uwp.cpp index 9f93c5a26b..8ed6473c37 100644 --- a/platform/winrt/joystick_winrt.cpp +++ b/platform/uwp/joystick_uwp.cpp @@ -1,11 +1,11 @@ /*************************************************************************/ -/* joystick.cpp */ +/* joystick_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -27,20 +27,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "joystick_winrt.h" +#include "joystick_uwp.h" using namespace Windows::Gaming::Input; using namespace Windows::Foundation; -void JoystickWinrt::register_events() { +void JoystickUWP::register_events() { Gamepad::GamepadAdded += - ref new EventHandler<Gamepad^>(this, &JoystickWinrt::OnGamepadAdded); + ref new EventHandler<Gamepad^>(this, &JoystickUWP::OnGamepadAdded); Gamepad::GamepadRemoved += - ref new EventHandler<Gamepad^>(this, &JoystickWinrt::OnGamepadRemoved); + ref new EventHandler<Gamepad^>(this, &JoystickUWP::OnGamepadRemoved); } -uint32_t JoystickWinrt::process_controllers(uint32_t p_last_id) { +uint32_t JoystickUWP::process_controllers(uint32_t p_last_id) { for (int i = 0; i < MAX_CONTROLLERS; i++) { @@ -74,20 +74,20 @@ uint32_t JoystickWinrt::process_controllers(uint32_t p_last_id) { return p_last_id; } -JoystickWinrt::JoystickWinrt() { +JoystickUWP::JoystickUWP() { for (int i = 0; i < MAX_CONTROLLERS; i++) controllers[i].id = i; } -JoystickWinrt::JoystickWinrt(InputDefault * p_input) { +JoystickUWP::JoystickUWP(InputDefault * p_input) { input = p_input; - JoystickWinrt(); + JoystickUWP(); } -void JoystickWinrt::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { +void JoystickUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { short idx = -1; @@ -106,10 +106,10 @@ void JoystickWinrt::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::I controllers[idx].id = idx; controllers[idx].type = ControllerType::GAMEPAD_CONTROLLER; - input->joy_connection_changed(controllers[idx].id, true, "Xbox Controller", "__WINRT_GAMEPAD__"); + input->joy_connection_changed(controllers[idx].id, true, "Xbox Controller", "__UWP_GAMEPAD__"); } -void JoystickWinrt::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { +void JoystickUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) { short idx = -1; @@ -136,7 +136,7 @@ void JoystickWinrt::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming: input->joy_connection_changed(idx, false, "Xbox Controller"); } -InputDefault::JoyAxis JoystickWinrt::axis_correct(double p_val, bool p_negate, bool p_trigger) const { +InputDefault::JoyAxis JoystickUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const { InputDefault::JoyAxis jx; diff --git a/platform/winrt/joystick_winrt.h b/platform/uwp/joystick_uwp.h index 17f9565708..f854f0b471 100644 --- a/platform/winrt/joystick_winrt.h +++ b/platform/uwp/joystick_uwp.h @@ -1,11 +1,11 @@ /*************************************************************************/ -/* joystick.h */ +/* joystick_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -26,20 +26,20 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JOYSTICK_WINRT_H -#define JOYSTICK_WINRT_H +#ifndef JOYSTICK_UWP_H +#define JOYSTICK_UWP_H #include "main/input_default.h" -ref class JoystickWinrt sealed { +ref class JoystickUWP sealed { internal: void register_events(); uint32_t process_controllers(uint32_t p_last_id); - JoystickWinrt(); - JoystickWinrt(InputDefault* p_input); + JoystickUWP(); + JoystickUWP(InputDefault* p_input); private: diff --git a/platform/winrt/logo.png b/platform/uwp/logo.png Binary files differindex 4376abd563..4376abd563 100644 --- a/platform/winrt/logo.png +++ b/platform/uwp/logo.png diff --git a/platform/winrt/os_winrt.cpp b/platform/uwp/os_uwp.cpp index 0ce561f88a..387cfe579f 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/uwp/os_uwp.cpp @@ -1,11 +1,11 @@ /*************************************************************************/ -/* os_winrt.cpp */ +/* os_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -27,11 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "drivers/gles2/rasterizer_gles2.h" -#include "os_winrt.h" -#include "drivers/nedmalloc/memory_pool_static_nedmalloc.h" +#include "os_uwp.h" #include "drivers/unix/memory_pool_static_malloc.h" #include "os/memory_pool_dynamic_static.h" -#include "thread_winrt.h" +#include "thread_uwp.h" #include "drivers/windows/semaphore_windows.h" #include "drivers/windows/mutex_windows.h" #include "main/main.h" @@ -70,28 +69,28 @@ using namespace Windows::ApplicationModel::DataTransfer; using namespace concurrency; -int OSWinrt::get_video_driver_count() const { +int OSUWP::get_video_driver_count() const { return 1; } -const char * OSWinrt::get_video_driver_name(int p_driver) const { +const char * OSUWP::get_video_driver_name(int p_driver) const { return "GLES2"; } -OS::VideoMode OSWinrt::get_default_video_mode() const { +OS::VideoMode OSUWP::get_default_video_mode() const { return video_mode; } -Size2 OSWinrt::get_window_size() const { +Size2 OSUWP::get_window_size() const { Size2 size; size.width = video_mode.width; size.height = video_mode.height; return size; } -void OSWinrt::set_window_size(const Size2 p_size) { +void OSUWP::set_window_size(const Size2 p_size) { Windows::Foundation::Size new_size; new_size.Width = p_size.width; @@ -106,7 +105,7 @@ void OSWinrt::set_window_size(const Size2 p_size) { } } -void OSWinrt::set_window_fullscreen(bool p_enabled) { +void OSUWP::set_window_fullscreen(bool p_enabled) { ApplicationView^ view = ApplicationView::GetForCurrentView(); @@ -127,12 +126,12 @@ void OSWinrt::set_window_fullscreen(bool p_enabled) { } } -bool OSWinrt::is_window_fullscreen() const { +bool OSUWP::is_window_fullscreen() const { return ApplicationView::GetForCurrentView()->IsFullScreenMode; } -void OSWinrt::set_keep_screen_on(bool p_enabled) { +void OSUWP::set_keep_screen_on(bool p_enabled) { if (is_keep_screen_on() == p_enabled) return; @@ -144,11 +143,11 @@ void OSWinrt::set_keep_screen_on(bool p_enabled) { OS::set_keep_screen_on(p_enabled); } -int OSWinrt::get_audio_driver_count() const { +int OSUWP::get_audio_driver_count() const { return AudioDriverManagerSW::get_driver_count(); } -const char * OSWinrt::get_audio_driver_name(int p_driver) const { +const char * OSUWP::get_audio_driver_name(int p_driver) const { AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver); ERR_FAIL_COND_V( !driver, "" ); @@ -158,14 +157,14 @@ const char * OSWinrt::get_audio_driver_name(int p_driver) const { static MemoryPoolStatic *mempool_static=NULL; static MemoryPoolDynamic *mempool_dynamic=NULL; -void OSWinrt::initialize_core() { +void OSUWP::initialize_core() { last_button_state=0; //RedirectIOToConsole(); - ThreadWinrt::make_default(); + ThreadUWP::make_default(); SemaphoreWindows::make_default(); MutexWindows::make_default(); @@ -207,23 +206,23 @@ void OSWinrt::initialize_core() { cursor_shape=CURSOR_ARROW; } -bool OSWinrt::can_draw() const { +bool OSUWP::can_draw() const { return !minimized; }; -void OSWinrt::set_gl_context(ContextEGL* p_context) { +void OSUWP::set_gl_context(ContextEGL* p_context) { gl_context = p_context; }; -void OSWinrt::screen_size_changed() { +void OSUWP::screen_size_changed() { gl_context->reset(); }; -void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { +void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { main_loop=NULL; outside=true; @@ -286,7 +285,7 @@ void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_aud input = memnew( InputDefault ); - joystick = ref new JoystickWinrt(input); + joystick = ref new JoystickUWP(input); joystick->register_events(); AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -346,7 +345,7 @@ void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_aud } -void OSWinrt::set_clipboard(const String& p_text) { +void OSUWP::set_clipboard(const String& p_text) { DataPackage^ clip = ref new DataPackage(); clip->RequestedOperation = DataPackageOperation::Copy; @@ -355,7 +354,7 @@ void OSWinrt::set_clipboard(const String& p_text) { Clipboard::SetContent(clip); }; -String OSWinrt::get_clipboard() const { +String OSUWP::get_clipboard() const { if (managed_object->clipboard != nullptr) return managed_object->clipboard->Data(); @@ -364,7 +363,7 @@ String OSWinrt::get_clipboard() const { }; -void OSWinrt::input_event(InputEvent &p_event) { +void OSUWP::input_event(InputEvent &p_event) { p_event.ID = ++last_id; @@ -379,20 +378,20 @@ void OSWinrt::input_event(InputEvent &p_event) { } }; -void OSWinrt::delete_main_loop() { +void OSUWP::delete_main_loop() { if (main_loop) memdelete(main_loop); main_loop=NULL; } -void OSWinrt::set_main_loop( MainLoop * p_main_loop ) { +void OSUWP::set_main_loop( MainLoop * p_main_loop ) { input->set_main_loop(p_main_loop); main_loop=p_main_loop; } -void OSWinrt::finalize() { +void OSUWP::finalize() { if(main_loop) memdelete(main_loop); @@ -433,7 +432,7 @@ void OSWinrt::finalize() { joystick = nullptr; } -void OSWinrt::finalize_core() { +void OSUWP::finalize_core() { if (mempool_dynamic) memdelete( mempool_dynamic ); @@ -441,7 +440,7 @@ void OSWinrt::finalize_core() { } -void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { +void OSUWP::vprint(const char* p_format, va_list p_list, bool p_stderr) { char buf[16384+1]; int len = vsnprintf(buf,16384,p_format,p_list); @@ -468,14 +467,14 @@ void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { fflush(stdout); }; -void OSWinrt::alert(const String& p_alert,const String& p_title) { +void OSUWP::alert(const String& p_alert,const String& p_title) { Platform::String^ alert = ref new Platform::String(p_alert.c_str()); Platform::String^ title = ref new Platform::String(p_title.c_str()); MessageDialog^ msg = ref new MessageDialog(alert, title); - UICommand^ close = ref new UICommand("Close", ref new UICommandInvokedHandler(managed_object, &OSWinrt::ManagedType::alert_close)); + UICommand^ close = ref new UICommand("Close", ref new UICommandInvokedHandler(managed_object, &OSUWP::ManagedType::alert_close)); msg->Commands->Append(close); msg->DefaultCommandIndex = 0; @@ -484,17 +483,17 @@ void OSWinrt::alert(const String& p_alert,const String& p_title) { msg->ShowAsync(); } -void OSWinrt::ManagedType::alert_close(IUICommand^ command) { +void OSUWP::ManagedType::alert_close(IUICommand^ command) { alert_close_handle = false; } -void OSWinrt::ManagedType::on_clipboard_changed(Platform::Object ^ sender, Platform::Object ^ ev) { +void OSUWP::ManagedType::on_clipboard_changed(Platform::Object ^ sender, Platform::Object ^ ev) { update_clipboard(); } -void OSWinrt::ManagedType::update_clipboard() { +void OSUWP::ManagedType::update_clipboard() { DataPackageView^ data = Clipboard::GetContent(); @@ -508,7 +507,7 @@ void OSWinrt::ManagedType::update_clipboard() { } } -void OSWinrt::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sender, AccelerometerReadingChangedEventArgs ^ args) { +void OSUWP::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sender, AccelerometerReadingChangedEventArgs ^ args) { AccelerometerReading^ reading = args->Reading; @@ -519,7 +518,7 @@ void OSWinrt::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ send )); } -void OSWinrt::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender, MagnetometerReadingChangedEventArgs ^ args) { +void OSUWP::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender, MagnetometerReadingChangedEventArgs ^ args) { MagnetometerReading^ reading = args->Reading; @@ -530,7 +529,7 @@ void OSWinrt::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender )); } -void OSWinrt::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, GyrometerReadingChangedEventArgs ^ args) { +void OSUWP::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, GyrometerReadingChangedEventArgs ^ args) { GyrometerReading^ reading = args->Reading; @@ -541,7 +540,7 @@ void OSWinrt::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, Gyro )); } -void OSWinrt::set_mouse_mode(MouseMode p_mode) { +void OSUWP::set_mouse_mode(MouseMode p_mode) { if (p_mode == MouseMode::MOUSE_MODE_CAPTURED) { @@ -567,41 +566,41 @@ void OSWinrt::set_mouse_mode(MouseMode p_mode) { SetEvent(mouse_mode_changed); } -OSWinrt::MouseMode OSWinrt::get_mouse_mode() const{ +OSUWP::MouseMode OSUWP::get_mouse_mode() const{ return mouse_mode; } -Point2 OSWinrt::get_mouse_pos() const { +Point2 OSUWP::get_mouse_pos() const { return Point2(old_x, old_y); } -int OSWinrt::get_mouse_button_state() const { +int OSUWP::get_mouse_button_state() const { return last_button_state; } -void OSWinrt::set_window_title(const String& p_title) { +void OSUWP::set_window_title(const String& p_title) { } -void OSWinrt::set_video_mode(const VideoMode& p_video_mode,int p_screen) { +void OSUWP::set_video_mode(const VideoMode& p_video_mode,int p_screen) { video_mode = p_video_mode; } -OS::VideoMode OSWinrt::get_video_mode(int p_screen) const { +OS::VideoMode OSUWP::get_video_mode(int p_screen) const { return video_mode; } -void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { +void OSUWP::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { } -void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { +void OSUWP::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { const char* err_details; if (p_rationale && p_rationale[0]) @@ -626,12 +625,12 @@ void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line } -String OSWinrt::get_name() { +String OSUWP::get_name() { - return "WinRT"; + return "UWP"; } -OS::Date OSWinrt::get_date(bool utc) const { +OS::Date OSUWP::get_date(bool utc) const { SYSTEMTIME systemtime; if (utc) @@ -647,7 +646,7 @@ OS::Date OSWinrt::get_date(bool utc) const { date.dst=false; return date; } -OS::Time OSWinrt::get_time(bool utc) const { +OS::Time OSUWP::get_time(bool utc) const { SYSTEMTIME systemtime; if (utc) @@ -662,7 +661,7 @@ OS::Time OSWinrt::get_time(bool utc) const { return time; } -OS::TimeZoneInfo OSWinrt::get_time_zone_info() const { +OS::TimeZoneInfo OSUWP::get_time_zone_info() const { TIME_ZONE_INFORMATION info; bool daylight = false; if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) @@ -679,7 +678,7 @@ OS::TimeZoneInfo OSWinrt::get_time_zone_info() const { return ret; } -uint64_t OSWinrt::get_unix_time() const { +uint64_t OSUWP::get_unix_time() const { FILETIME ft; SYSTEMTIME st; @@ -701,7 +700,7 @@ uint64_t OSWinrt::get_unix_time() const { return (*(uint64_t*)&ft - *(uint64_t*)&fep) / 10000000; }; -void OSWinrt::delay_usec(uint32_t p_usec) const { +void OSUWP::delay_usec(uint32_t p_usec) const { int msec = p_usec < 1000 ? 1 : p_usec / 1000; @@ -709,7 +708,7 @@ void OSWinrt::delay_usec(uint32_t p_usec) const { WaitForSingleObjectEx(GetCurrentThread(), msec, false); } -uint64_t OSWinrt::get_ticks_usec() const { +uint64_t OSUWP::get_ticks_usec() const { uint64_t ticks; uint64_t time; @@ -724,13 +723,13 @@ uint64_t OSWinrt::get_ticks_usec() const { } -void OSWinrt::process_events() { +void OSUWP::process_events() { last_id = joystick->process_controllers(last_id); process_key_events(); } -void OSWinrt::process_key_events() +void OSUWP::process_key_events() { for (int i = 0; i < key_event_pos; i++) { @@ -751,7 +750,7 @@ void OSWinrt::process_key_events() key_event_pos = 0; } -void OSWinrt::queue_key_event(KeyEvent & p_event) +void OSUWP::queue_key_event(KeyEvent & p_event) { // This merges Char events with the previous Key event, so // the unicode can be retrieved without sending duplicate events. @@ -769,7 +768,7 @@ void OSWinrt::queue_key_event(KeyEvent & p_event) key_event_buffer[key_event_pos++] = p_event; } -void OSWinrt::set_cursor_shape(CursorShape p_shape) { +void OSUWP::set_cursor_shape(CursorShape p_shape) { ERR_FAIL_INDEX(p_shape, CURSOR_MAX); @@ -801,58 +800,58 @@ void OSWinrt::set_cursor_shape(CursorShape p_shape) { cursor_shape = p_shape; } -Error OSWinrt::execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id,String* r_pipe,int *r_exitcode) { +Error OSUWP::execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id,String* r_pipe,int *r_exitcode) { return FAILED; }; -Error OSWinrt::kill(const ProcessID& p_pid) { +Error OSUWP::kill(const ProcessID& p_pid) { return FAILED; }; -Error OSWinrt::set_cwd(const String& p_cwd) { +Error OSUWP::set_cwd(const String& p_cwd) { return FAILED; } -String OSWinrt::get_executable_path() const { +String OSUWP::get_executable_path() const { return ""; } -void OSWinrt::set_icon(const Image& p_icon) { +void OSUWP::set_icon(const Image& p_icon) { } -bool OSWinrt::has_environment(const String& p_var) const { +bool OSUWP::has_environment(const String& p_var) const { return false; }; -String OSWinrt::get_environment(const String& p_var) const { +String OSUWP::get_environment(const String& p_var) const { return ""; }; -String OSWinrt::get_stdin_string(bool p_block) { +String OSUWP::get_stdin_string(bool p_block) { return String(); } -void OSWinrt::move_window_to_foreground() { +void OSUWP::move_window_to_foreground() { } -Error OSWinrt::shell_open(String p_uri) { +Error OSUWP::shell_open(String p_uri) { return FAILED; } -String OSWinrt::get_locale() const { +String OSUWP::get_locale() const { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // this should work on phone 8.1, but it doesn't return "en"; @@ -862,46 +861,46 @@ String OSWinrt::get_locale() const { #endif } -void OSWinrt::release_rendering_thread() { +void OSUWP::release_rendering_thread() { gl_context->release_current(); } -void OSWinrt::make_rendering_thread() { +void OSUWP::make_rendering_thread() { gl_context->make_current(); } -void OSWinrt::swap_buffers() { +void OSUWP::swap_buffers() { gl_context->swap_buffers(); } -bool OSWinrt::has_touchscreen_ui_hint() const { +bool OSUWP::has_touchscreen_ui_hint() const { TouchCapabilities^ tc = ref new TouchCapabilities(); return tc->TouchPresent != 0 || UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch; } -bool OSWinrt::has_virtual_keyboard() const { +bool OSUWP::has_virtual_keyboard() const { return UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch; } -void OSWinrt::show_virtual_keyboard(const String & p_existing_text, const Rect2 & p_screen_rect) { +void OSUWP::show_virtual_keyboard(const String & p_existing_text, const Rect2 & p_screen_rect) { InputPane^ pane = InputPane::GetForCurrentView(); pane->TryShow(); } -void OSWinrt::hide_virtual_keyboard() { +void OSUWP::hide_virtual_keyboard() { InputPane^ pane = InputPane::GetForCurrentView(); pane->TryHide(); } -void OSWinrt::run() { +void OSUWP::run() { if (!main_loop) return; @@ -928,13 +927,13 @@ void OSWinrt::run() { -MainLoop *OSWinrt::get_main_loop() const { +MainLoop *OSUWP::get_main_loop() const { return main_loop; } -String OSWinrt::get_data_dir() const { +String OSUWP::get_data_dir() const { Windows::Storage::StorageFolder ^data_folder = Windows::Storage::ApplicationData::Current->LocalFolder; @@ -942,7 +941,7 @@ String OSWinrt::get_data_dir() const { } -OSWinrt::OSWinrt() { +OSUWP::OSUWP() { key_event_pos=0; force_quit=false; @@ -974,7 +973,7 @@ OSWinrt::OSWinrt() { } -OSWinrt::~OSWinrt() +OSUWP::~OSUWP() { #ifdef STDOUT_FILE fclose(stdo); diff --git a/platform/winrt/os_winrt.h b/platform/uwp/os_uwp.h index 1816e0cec7..c50d34aca2 100644 --- a/platform/winrt/os_winrt.h +++ b/platform/uwp/os_uwp.h @@ -1,11 +1,11 @@ /*************************************************************************/ -/* os_winrt.h */ +/* os_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OSWinrt_H -#define OSWinrt_H +#ifndef OSUWP_H +#define OSUWP_H #include "os/input.h" #include "os/os.h" @@ -40,7 +40,7 @@ #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" -#include "audio_driver_winrt.h" +#include "drivers/xaudio2/audio_driver_xaudio2.h" #include "gl_context_egl.h" @@ -55,12 +55,12 @@ #include <stdio.h> #include "main/input_default.h" -#include "joystick_winrt.h" +#include "joystick_uwp.h" /** @author Juan Linietsky <reduzio@gmail.com> */ -class OSWinrt : public OS { +class OSUWP : public OS { public: @@ -118,7 +118,7 @@ private: MainLoop *main_loop; - AudioDriverWinRT audio_driver; + AudioDriverXAudio2 audio_driver; AudioServerSW *audio_server; SampleManagerMallocSW *sample_manager; SpatialSoundServerSW *spatial_sound_server; @@ -137,7 +137,7 @@ private: InputDefault *input; - JoystickWinrt^ joystick; + JoystickUWP^ joystick; Windows::System::Display::DisplayRequest^ display_request; @@ -159,7 +159,7 @@ private: internal: ManagedType() { alert_close_handle = false; } - property OSWinrt* os; + property OSUWP* os; }; ManagedType^ managed_object; Windows::Devices::Sensors::Accelerometer^ accelerometer; @@ -273,8 +273,8 @@ public: void queue_key_event(KeyEvent &p_event); - OSWinrt(); - ~OSWinrt(); + OSUWP(); + ~OSUWP(); }; diff --git a/platform/winrt/platform_config.h b/platform/uwp/platform_config.h index 88b1fefed8..7939e1c9ee 100644 --- a/platform/winrt/platform_config.h +++ b/platform/uwp/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/winrt/thread_winrt.cpp b/platform/uwp/thread_uwp.cpp index 8e3e0d5bef..4008a1eeb0 100644 --- a/platform/winrt/thread_winrt.cpp +++ b/platform/uwp/thread_uwp.cpp @@ -1,11 +1,11 @@ /*************************************************************************/ -/* thread_winrt.cpp */ +/* thread_uwp.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -26,13 +26,13 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "thread_winrt.h" +#include "thread_uwp.h" #include "os/memory.h" -Thread* ThreadWinrt::create_func_winrt(ThreadCreateCallback p_callback,void *p_user,const Settings&) { +Thread* ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback,void *p_user,const Settings&) { - ThreadWinrt* thread = memnew(ThreadWinrt); + ThreadUWP* thread = memnew(ThreadUWP); std::thread new_thread(p_callback, p_user); @@ -41,34 +41,34 @@ Thread* ThreadWinrt::create_func_winrt(ThreadCreateCallback p_callback,void *p_u return thread; }; -Thread::ID ThreadWinrt::get_thread_ID_func_winrt() { +Thread::ID ThreadUWP::get_thread_ID_func_uwp() { return std::hash<std::thread::id>()(std::this_thread::get_id()); }; -void ThreadWinrt::wait_to_finish_func_winrt(Thread* p_thread) { +void ThreadUWP::wait_to_finish_func_uwp(Thread* p_thread) { - ThreadWinrt *tp=static_cast<ThreadWinrt*>(p_thread); + ThreadUWP *tp=static_cast<ThreadUWP*>(p_thread); tp->thread.join(); }; -Thread::ID ThreadWinrt::get_ID() const { +Thread::ID ThreadUWP::get_ID() const { return std::hash<std::thread::id>()(thread.get_id()); }; -void ThreadWinrt::make_default() { - create_func = create_func_winrt; - get_thread_ID_func = get_thread_ID_func_winrt; - wait_to_finish_func = wait_to_finish_func_winrt; +void ThreadUWP::make_default() { + create_func = create_func_uwp; + get_thread_ID_func = get_thread_ID_func_uwp; + wait_to_finish_func = wait_to_finish_func_uwp; }; -ThreadWinrt::ThreadWinrt() { +ThreadUWP::ThreadUWP() { }; -ThreadWinrt::~ThreadWinrt() { +ThreadUWP::~ThreadUWP() { }; diff --git a/platform/winrt/thread_winrt.h b/platform/uwp/thread_uwp.h index df275d560a..06c19c0139 100644 --- a/platform/winrt/thread_winrt.h +++ b/platform/uwp/thread_uwp.h @@ -1,11 +1,11 @@ /*************************************************************************/ -/* thread_winrt.h */ +/* thread_uwp.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -26,24 +26,24 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef THREAD_WINRT_H -#define THREAD_WINRT_H +#ifndef THREAD_UWP_H +#define THREAD_UWP_H -#ifdef WINRT_ENABLED +#ifdef UWP_ENABLED #include "os/thread.h" #include <thread> -class ThreadWinrt : public Thread { +class ThreadUWP : public Thread { std::thread thread; - static Thread* create_func_winrt(ThreadCreateCallback p_callback,void *,const Settings&); - static ID get_thread_ID_func_winrt(); - static void wait_to_finish_func_winrt(Thread* p_thread); + static Thread* create_func_uwp(ThreadCreateCallback p_callback,void *,const Settings&); + static ID get_thread_ID_func_uwp(); + static void wait_to_finish_func_uwp(Thread* p_thread); - ThreadWinrt(); + ThreadUWP(); public: @@ -52,7 +52,7 @@ public: static void make_default(); - ~ThreadWinrt(); + ~ThreadUWP(); }; diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 914cee0fa1..32c23b906a 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -1,27 +1,29 @@ +#!/usr/bin/env python + Import('env') -common_win=[ - "context_gl_win.cpp", - "os_windows.cpp", - "ctxgl_procaddr.cpp", - "key_mapping_win.cpp", - "tcp_server_winsock.cpp", - "packet_peer_udp_winsock.cpp", - "stream_peer_winsock.cpp", - "joystick.cpp", +common_win = [ + "context_gl_win.cpp", + "os_windows.cpp", + "ctxgl_procaddr.cpp", + "key_mapping_win.cpp", + "tcp_server_winsock.cpp", + "packet_peer_udp_winsock.cpp", + "stream_peer_winsock.cpp", + "joystick.cpp", ] -restarget="godot_res"+env["OBJSUFFIX"] +restarget = "godot_res" + env["OBJSUFFIX"] -obj = env.RES(restarget,'godot_res.rc') +obj = env.RES(restarget, 'godot_res.rc') common_win.append(obj) -env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]) +env.Program('#bin/godot', ['godot_win.cpp'] + common_win, PROGSUFFIX=env["PROGSUFFIX"]) # Microsoft Visual Studio Project Generation -if (env['vsproj'])=="yes": - env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] - for x in common_win: - env.vs_srcs = env.vs_srcs + ["platform/windows/" + str(x)] +if (env['vsproj']) == "yes": + env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] + for x in common_win: + env.vs_srcs = env.vs_srcs + ["platform/windows/" + str(x)] diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index fd9e895370..136ac310f6 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -110,6 +110,7 @@ bool ContextGL_Win::is_using_vsync() const { return use_vsync; } +#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 Error ContextGL_Win::initialize() { @@ -162,10 +163,10 @@ Error ContextGL_Win::initialize() { if (opengl_3_context) { int attribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.1 context - WGL_CONTEXT_MINOR_VERSION_ARB, 2, + WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.3 context + WGL_CONTEXT_MINOR_VERSION_ARB, 3, //and it shall be forward compatible so that we can only use up to date functionality - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB|_WGL_CONTEXT_DEBUG_BIT_ARB, 0}; //zero indicates the end of the array PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; //pointer to the method @@ -182,7 +183,7 @@ Error ContextGL_Win::initialize() { if (!(new_hRC=wglCreateContextAttribsARB(hDC,0, attribs))) { wglDeleteContext(hRC); - MessageBox(NULL,"Can't Create An OpenGL 3.1 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); + MessageBox(NULL,"Can't Create An OpenGL 3.3 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return false } wglMakeCurrent(hDC,NULL); @@ -191,11 +192,11 @@ Error ContextGL_Win::initialize() { if (!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { - MessageBox(NULL,"Can't Activate The GL 3.1 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); + MessageBox(NULL,"Can't Activate The GL 3.3 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } - printf("Activated GL 3.1 context"); + printf("Activated GL 3.3 context"); } wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress ("wglSwapIntervalEXT"); diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h index e1ab6fb26a..96b54c6c14 100644 --- a/platform/windows/context_gl_win.h +++ b/platform/windows/context_gl_win.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/ctxgl_procaddr.cpp b/platform/windows/ctxgl_procaddr.cpp index 1072197f89..bc8611dce4 100644 --- a/platform/windows/ctxgl_procaddr.cpp +++ b/platform/windows/ctxgl_procaddr.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/ctxgl_procaddr.h b/platform/windows/ctxgl_procaddr.h index 2118e20e02..72f39e71ac 100644 --- a/platform/windows/ctxgl_procaddr.h +++ b/platform/windows/ctxgl_procaddr.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/detect.py b/platform/windows/detect.py index 12ea5a93ee..28030afa82 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -1,16 +1,11 @@ # -# tested on | Windows native | Linux cross-compilation -# ----------------------------+-------------------+--------------------------- -# MSVS C++ 2010 Express | WORKS | n/a +# tested on | Windows native | Linux cross-compilation +# ----------------------------+-------------------+--------------------------- # Visual C++ Build Tools 2015 | WORKS | n/a -# Mingw-w64 | WORKS | WORKS -# Mingw-w32 | WORKS | WORKS -# MinGW | WORKS | untested -# -##### -# Notes about MSVS C++ : -# -# - MSVC2010-Express compiles to 32bits only. +# MSVS C++ 2010 Express | WORKS | n/a +# Mingw-w64 | WORKS | WORKS +# Mingw-w32 | WORKS | WORKS +# MinGW | WORKS | untested # ##### # Note about Visual C++ Build Tools : @@ -19,6 +14,11 @@ # http://landinghub.visualstudio.com/visual-cpp-build-tools # ##### +# Notes about MSVS C++ : +# +# - MSVC2010-Express compiles to 32bits only. +# +##### # Notes about Mingw-w64 and Mingw-w32 under Windows : # # - both can be installed using the official installer : @@ -85,7 +85,7 @@ ##### # TODO : -# +# # - finish to cleanup this script to remove all the remains of previous hacks and workarounds # - make it work with the Windows7 SDK that is supposed to enable 64bits compilation for MSVC2010-Express # - confirm it works well with other Visual Studio versions. @@ -99,300 +99,295 @@ import sys import methods -def is_active(): - return True - -def get_name(): - return "Windows" - -def can_build(): - - if (os.name=="nt"): - #building natively on windows! - if ( methods.msvc_is_detected() ): - return True - else: - print("\nMSVC not detected, attempting Mingw.") - mingw32 = "" - mingw64 = "" - if ( os.getenv("MINGW32_PREFIX") ) : - mingw32 = os.getenv("MINGW32_PREFIX") - if ( os.getenv("MINGW64_PREFIX") ) : - mingw64 = os.getenv("MINGW64_PREFIX") - - test = "gcc --version > NUL 2>&1" - if os.system(test)!= 0 and os.system(mingw32+test)!=0 and os.system(mingw64+test)!=0 : - print("- could not detect gcc.") - print("Please, make sure a path to a Mingw /bin directory is accessible into the environment PATH.\n") - return False - else: - print("- gcc detected.") - - return True - - if (os.name=="posix"): - - mingw = "i586-mingw32msvc-" - mingw64 = "x86_64-w64-mingw32-" - mingw32 = "i686-w64-mingw32-" - - if (os.getenv("MINGW32_PREFIX")): - mingw32=os.getenv("MINGW32_PREFIX") - mingw = mingw32 - if (os.getenv("MINGW64_PREFIX")): - mingw64=os.getenv("MINGW64_PREFIX") - - test = "gcc --version &>/dev/null" - if (os.system(mingw+test) == 0 or os.system(mingw64+test) == 0 or os.system(mingw32+test) == 0): - return True - - return False - -def get_opts(): - - mingw="" - mingw32="" - mingw64="" - if ( os.name == "posix" ): - mingw = "i586-mingw32msvc-" - mingw32 = "i686-w64-mingw32-" - mingw64 = "x86_64-w64-mingw32-" - - if os.system(mingw32+"gcc --version &>/dev/null") != 0 : - mingw32 = mingw - - if (os.getenv("MINGW32_PREFIX")): - mingw32=os.getenv("MINGW32_PREFIX") - mingw = mingw32 - if (os.getenv("MINGW64_PREFIX")): - mingw64=os.getenv("MINGW64_PREFIX") - - return [ - ('mingw_prefix','Mingw Prefix',mingw32), - ('mingw_prefix_64','Mingw Prefix 64 bits',mingw64), - ] - -def get_flags(): - - return [ - ('glew','yes'), - ('openssl','builtin'), #use builtin openssl - ] - -def build_res_file( target, source, env ): - - cmdbase = "" - if (env["bits"] == "32"): - cmdbase = env['mingw_prefix'] - else: - cmdbase = env['mingw_prefix_64'] - CPPPATH = env['CPPPATH'] - cmdbase = cmdbase + 'windres --include-dir . ' - import subprocess - for x in range(len(source)): - cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x]) - try: - out = subprocess.Popen(cmd,shell = True,stderr = subprocess.PIPE).communicate() - if len(out[1]): - return 1 - except: - return 1 - return 0 - -def configure(env): - - env.Append(CPPPATH=['#platform/windows']) - env['is_mingw']=False - if (os.name=="nt" and methods.msvc_is_detected() ): - #build using visual studio - env['ENV']['TMP'] = os.environ['TMP'] - env.Append(CPPPATH=['#platform/windows/include']) - env.Append(LIBPATH=['#platform/windows/lib']) - - - if (env["target"]=="release"): - - env.Append(CCFLAGS=['/O2']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) - env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - elif (env["target"]=="debug_release"): - - env.Append(CCFLAGS=['/Z7','/Od']) - env.Append(LINKFLAGS=['/DEBUG']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) - env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['/Z7','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/Od']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/DEBUG']) - - - env.Append(CCFLAGS=['/MT','/Gd','/GR','/nologo']) - env.Append(CXXFLAGS=['/TP']) - env.Append(CPPFLAGS=['/DMSVC', '/GR', ]) - env.Append(CCFLAGS=['/I'+os.getenv("WindowsSdkDir")+"/Include"]) - env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) - env.Append(CCFLAGS=['/DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['/DWIN32']) - env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) - - env.Append(CCFLAGS=['/DGLES2_ENABLED']) - LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32','Ws2_32', 'shell32','advapi32','dinput8','dxguid'] - env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS]) - - env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"]) - if (os.getenv("DXSDK_DIR")): - DIRECTX_PATH=os.getenv("DXSDK_DIR") - else: - DIRECTX_PATH="C:/Program Files/Microsoft DirectX SDK (March 2009)" - - if (os.getenv("VCINSTALLDIR")): - VC_PATH=os.getenv("VCINSTALLDIR") - else: - VC_PATH="" - - env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")]) - env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) - env.Append(CCFLAGS=["/I"+DIRECTX_PATH+"/Include"]) - env.Append(LIBPATH=[DIRECTX_PATH+"/Lib/x86"]) - env['ENV'] = os.environ; - - # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) - - # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows) - if(env["bits"] != "default"): - print "Error: bits argument is disabled for MSVC" - print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" - +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler" - +" will be executed and inform you.") - sys.exit() - - # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt - # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with) - env["bits"]="32" - env["x86_opt_vc"]=True - - print "Detected MSVC compiler: "+compiler_version_str - # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm - if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): - env["bits"]="64" - env["x86_opt_vc"]=False - print "Compiled program architecture will be a 64 bit executable (forcing bits=64)." - elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"): - print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)." - else: - print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." - if env["bits"]=="64": - env.Append(CCFLAGS=['/D_WIN64']) - - # Incremental linking fix - env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] - env['BUILDERS']['Program'] = methods.precious_program - - else: - - # Workaround for MinGW. See: - # http://www.scons.org/wiki/LongCmdLinesOnWin32 - env.use_windows_spawn_fix() - - #build using mingw - if (os.name=="nt"): - env['ENV']['TMP'] = os.environ['TMP'] #way to go scons, you can be so stupid sometimes - else: - env["PROGSUFFIX"]=env["PROGSUFFIX"]+".exe" # for linux cross-compilation - - mingw_prefix="" +def is_active(): + return True - if (env["bits"]=="default"): - env["bits"]="32" - if (env["bits"]=="32"): - env.Append(LINKFLAGS=['-static']) - env.Append(LINKFLAGS=['-static-libgcc']) - env.Append(LINKFLAGS=['-static-libstdc++']) - mingw_prefix=env["mingw_prefix"]; - else: - env.Append(LINKFLAGS=['-static']) - mingw_prefix=env["mingw_prefix_64"]; +def get_name(): + return "Windows" - nulstr="" - if (os.name=="posix"): - nulstr=">/dev/null" - else: - nulstr=">nul" +def can_build(): + if (os.name == "nt"): + # building natively on windows! + if (os.getenv("VCINSTALLDIR")): + return True + else: + print("\nMSVC not detected, attempting Mingw.") + mingw32 = "" + mingw64 = "" + if (os.getenv("MINGW32_PREFIX")): + mingw32 = os.getenv("MINGW32_PREFIX") + if (os.getenv("MINGW64_PREFIX")): + mingw64 = os.getenv("MINGW64_PREFIX") + test = "gcc --version > NUL 2>&1" + if os.system(test) != 0 and os.system(mingw32 + test) != 0 and os.system(mingw64 + test) != 0: + print("- could not detect gcc.") + print("Please, make sure a path to a Mingw /bin directory is accessible into the environment PATH.\n") + return False + else: + print("- gcc detected.") - # if os.system(mingw_prefix+"gcc --version"+nulstr)!=0: - # #not really super consistent but.. - # print("Can't find Windows compiler: "+mingw_prefix) - # sys.exit(255) + return True - if (env["target"]=="release"): + if (os.name == "posix"): - env.Append(CCFLAGS=['-msse2']) + mingw = "i586-mingw32msvc-" + mingw64 = "x86_64-w64-mingw32-" + mingw32 = "i686-w64-mingw32-" - if (env["bits"]=="64"): - env.Append(CCFLAGS=['-O3']) - else: - env.Append(CCFLAGS=['-O2']) + if (os.getenv("MINGW32_PREFIX")): + mingw32 = os.getenv("MINGW32_PREFIX") + mingw = mingw32 + if (os.getenv("MINGW64_PREFIX")): + mingw64 = os.getenv("MINGW64_PREFIX") - env.Append(LINKFLAGS=['-Wl,--subsystem,windows']) + test = "gcc --version &>/dev/null" + if (os.system(mingw + test) == 0 or os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0): + return True - elif (env["target"]=="release_debug"): + return False - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): +def get_opts(): - env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + mingw = "" + mingw32 = "" + mingw64 = "" + if (os.name == "posix"): + mingw = "i586-mingw32msvc-" + mingw32 = "i686-w64-mingw32-" + mingw64 = "x86_64-w64-mingw32-" + if os.system(mingw32 + "gcc --version &>/dev/null") != 0: + mingw32 = mingw + if (os.getenv("MINGW32_PREFIX")): + mingw32 = os.getenv("MINGW32_PREFIX") + mingw = mingw32 + if (os.getenv("MINGW64_PREFIX")): + mingw64 = os.getenv("MINGW64_PREFIX") - env["CC"]=mingw_prefix+"gcc" - env['AS']=mingw_prefix+"as" - env['CXX'] = mingw_prefix+"g++" - env['AR'] = mingw_prefix+"ar" - env['RANLIB'] = mingw_prefix+"ranlib" - env['LD'] = mingw_prefix+"g++" - env["x86_opt_gcc"]=True + return [ + ('mingw_prefix', 'Mingw Prefix', mingw32), + ('mingw_prefix_64', 'Mingw Prefix 64 bits', mingw64), + ] - #env['CC'] = "winegcc" - #env['CXX'] = "wineg++" - env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows']) - env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['-DGLES2_ENABLED']) - env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','ws2_32','kernel32', 'oleaut32', 'dinput8', 'dxguid']) +def get_flags(): - # if (env["bits"]=="32"): - # env.Append(LIBS=['gcc_s']) - # #--with-arch=i686 - # env.Append(CPPFLAGS=['-march=i686']) - # env.Append(LINKFLAGS=['-march=i686']) + return [ + ] +def build_res_file(target, source, env): + cmdbase = "" + if (env["bits"] == "32"): + cmdbase = env['mingw_prefix'] + else: + cmdbase = env['mingw_prefix_64'] + CPPPATH = env['CPPPATH'] + cmdbase = cmdbase + 'windres --include-dir . ' + import subprocess + for x in range(len(source)): + cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x]) + try: + out = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE).communicate() + if len(out[1]): + return 1 + except: + return 1 + return 0 - #'d3dx9d' - env.Append(CPPFLAGS=['-DMINGW_ENABLED']) - #env.Append(LINKFLAGS=['-g']) - # resrc - env['is_mingw']=True - env.Append( BUILDERS = { 'RES' : env.Builder(action = build_res_file, suffix = '.o',src_suffix = '.rc') } ) +def configure(env): - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_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.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) + env.Append(CPPPATH=['#platform/windows']) + env['is_mingw'] = False + if (os.name == "nt" and os.getenv("VCINSTALLDIR")): + # build using visual studio + env['ENV']['TMP'] = os.environ['TMP'] + env.Append(CPPPATH=['#platform/windows/include']) + env.Append(LIBPATH=['#platform/windows/lib']) + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['/O2']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) + env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['/O2', '/DDEBUG_ENABLED']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + elif (env["target"] == "debug_release"): + + env.Append(CCFLAGS=['/Z7', '/Od']) + env.Append(LINKFLAGS=['/DEBUG']) + env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) + env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['/Z7', '/DDEBUG_ENABLED', '/DDEBUG_MEMORY_ENABLED', '/DD3D_DEBUG_INFO', '/Od']) + env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + env.Append(LINKFLAGS=['/DEBUG']) + + env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo']) + env.Append(CXXFLAGS=['/TP']) + env.Append(CPPFLAGS=['/DMSVC', '/GR', ]) + env.Append(CCFLAGS=['/I' + os.getenv("WindowsSdkDir") + "/Include"]) + env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) + env.Append(CCFLAGS=['/DRTAUDIO_ENABLED']) + env.Append(CCFLAGS=['/DWIN32']) + env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) + + env.Append(CCFLAGS=['/DOPENGL_ENABLED']) + LIBS = ['winmm', 'opengl32', 'dsound', 'kernel32', 'ole32', 'oleaut32', 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'Ws2_32', 'shell32', 'advapi32', 'dinput8', 'dxguid'] + env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS]) + + env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"]) + if (os.getenv("DXSDK_DIR")): + DIRECTX_PATH = os.getenv("DXSDK_DIR") + else: + DIRECTX_PATH = "C:/Program Files/Microsoft DirectX SDK (March 2009)" + + if (os.getenv("VCINSTALLDIR")): + VC_PATH = os.getenv("VCINSTALLDIR") + else: + VC_PATH = "" + + env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")]) + env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) + env.Append(CCFLAGS=["/I" + DIRECTX_PATH + "/Include"]) + env.Append(LIBPATH=[DIRECTX_PATH + "/Lib/x86"]) + env['ENV'] = os.environ + + # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code + compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + + # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows) + if(env["bits"] != "default"): + print "Error: bits argument is disabled for MSVC" + print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" + + " that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler" + + " will be executed and inform you.") + sys.exit() + + # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt + # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with) + env["bits"] = "32" + env["x86_libtheora_opt_vc"] = True + + print "Detected MSVC compiler: " + compiler_version_str + # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm + if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + env["bits"] = "64" + env["x86_libtheora_opt_vc"] = False + print "Compiled program architecture will be a 64 bit executable (forcing bits=64)." + elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"): + print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)." + else: + print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + if env["bits"] == "64": + env.Append(CCFLAGS=['/D_WIN64']) + + # Incremental linking fix + env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] + env['BUILDERS']['Program'] = methods.precious_program + + else: + + # Workaround for MinGW. See: + # http://www.scons.org/wiki/LongCmdLinesOnWin32 + env.use_windows_spawn_fix() + + # build using mingw + if (os.name == "nt"): + env['ENV']['TMP'] = os.environ['TMP'] # way to go scons, you can be so stupid sometimes + else: + env["PROGSUFFIX"] = env["PROGSUFFIX"] + ".exe" # for linux cross-compilation + + mingw_prefix = "" + + if (env["bits"] == "default"): + env["bits"] = "32" + + if (env["bits"] == "32"): + env.Append(LINKFLAGS=['-static']) + env.Append(LINKFLAGS=['-static-libgcc']) + env.Append(LINKFLAGS=['-static-libstdc++']) + mingw_prefix = env["mingw_prefix"] + else: + env.Append(LINKFLAGS=['-static']) + mingw_prefix = env["mingw_prefix_64"] + + nulstr = "" + + if (os.name == "posix"): + nulstr = ">/dev/null" + else: + nulstr = ">nul" + + # if os.system(mingw_prefix+"gcc --version"+nulstr)!=0: + # #not really super consistent but.. + # print("Can't find Windows compiler: "+mingw_prefix) + # sys.exit(255) + + if (env["target"] == "release"): + + env.Append(CCFLAGS=['-msse2']) + + if (env["bits"] == "64"): + env.Append(CCFLAGS=['-O3']) + else: + env.Append(CCFLAGS=['-O2']) + + env.Append(LINKFLAGS=['-Wl,--subsystem,windows']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + env["CC"] = mingw_prefix + "gcc" + env['AS'] = mingw_prefix + "as" + env['CXX'] = mingw_prefix + "g++" + env['AR'] = mingw_prefix + "ar" + env['RANLIB'] = mingw_prefix + "ranlib" + env['LD'] = mingw_prefix + "g++" + env["x86_libtheora_opt_gcc"] = True + + #env['CC'] = "winegcc" + #env['CXX'] = "wineg++" + + env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows']) + env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) + env.Append(CCFLAGS=['-DOPENGL_ENABLED']) + env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid']) + + # if (env["bits"]=="32"): + # env.Append(LIBS=['gcc_s']) + # #--with-arch=i686 + # env.Append(CPPFLAGS=['-march=i686']) + # env.Append(LINKFLAGS=['-march=i686']) + + #'d3dx9d' + env.Append(CPPFLAGS=['-DMINGW_ENABLED']) + # env.Append(LINKFLAGS=['-g']) + + # resrc + env['is_mingw'] = True + env.Append(BUILDERS={'RES': env.Builder(action=build_res_file, suffix='.o', src_suffix='.rc')}) + + env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_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.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 9bf9ba93fe..1ad61844d0 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/export/export.h b/platform/windows/export/export.h index aa3578fb98..b437efc48e 100644 --- a/platform/windows/export/export.h +++ b/platform/windows/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/godot_win.cpp b/platform/windows/godot_win.cpp index c89d02bb05..5260f7f641 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/joystick.cpp b/platform/windows/joystick.cpp index e69bfe6a52..3fdf20a472 100644 --- a/platform/windows/joystick.cpp +++ b/platform/windows/joystick.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/joystick.h b/platform/windows/joystick.h index 77dee0466f..6de05bf108 100644 --- a/platform/windows/joystick.h +++ b/platform/windows/joystick.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/key_mapping_win.cpp b/platform/windows/key_mapping_win.cpp index 23fa29d68f..00a0ca79c7 100644 --- a/platform/windows/key_mapping_win.cpp +++ b/platform/windows/key_mapping_win.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/key_mapping_win.h b/platform/windows/key_mapping_win.h index da649d0115..2f1b36d9f2 100644 --- a/platform/windows/key_mapping_win.h +++ b/platform/windows/key_mapping_win.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/lang_table.h b/platform/windows/lang_table.h index c9551b2d38..bacbf89e85 100644 --- a/platform/windows/lang_table.h +++ b/platform/windows/lang_table.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 92359892a8..445f4fc328 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -26,10 +26,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "drivers/gles2/rasterizer_gles2.h" #include "os_windows.h" -#include "drivers/nedmalloc/memory_pool_static_nedmalloc.h" + +#include "drivers/gles3/rasterizer_gles3.h" #include "drivers/unix/memory_pool_static_malloc.h" #include "os/memory_pool_dynamic_static.h" #include "drivers/windows/thread_windows.h" @@ -42,7 +42,7 @@ #include "servers/visual/visual_server_raster.h" #include "servers/audio/audio_server_sw.h" -#include "servers/visual/visual_server_wrap_mt.h" +//#include "servers/visual/visual_server_wrap_mt.h" #include "tcp_server_winsock.h" #include "packet_peer_udp_winsock.h" @@ -1079,21 +1079,24 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ }; -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) || defined(LEGACYGL_ENABLED) - gl_context = memnew( ContextGL_Win(hWnd,false) ); +#if defined(OPENGL_ENABLED) + gl_context = memnew( ContextGL_Win(hWnd,true) ); gl_context->initialize(); - rasterizer = memnew( RasterizerGLES2 ); + + RasterizerGLES3::register_config(); + + RasterizerGLES3::make_current(); #else #ifdef DX9_ENABLED rasterizer = memnew( RasterizerDX9(hWnd) ); #endif #endif - visual_server = memnew( VisualServerRaster(rasterizer) ); - if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { - - visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); - } + visual_server = memnew( VisualServerRaster ); + //if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { +// +// visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); +// } // physics_server = memnew( PhysicsServerSW ); @@ -1330,10 +1333,18 @@ void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) { MultiByteToWideChar(CP_UTF8,0,buf,len,wbuf,wlen); wbuf[wlen]=0; +// Recent MinGW and MSVC compilers seem to disagree on the case here +#ifdef __MINGW32__ if (p_stderr) - fwprintf(stderr,L"%s",wbuf); + fwprintf(stderr, L"%S", wbuf); else - wprintf(L"%s",wbuf); + wprintf(L"%S", wbuf); +#else // MSVC + if (p_stderr) + fwprintf(stderr, L"%s", wbuf); + else + wprintf(L"%s", wbuf); +#endif #ifdef STDOUT_FILE //vwfprintf(stdo,p_format,p_list); @@ -1367,13 +1378,16 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) { POINT pos = { (int) center.x, (int) center.y }; ClientToScreen(hWnd, &pos); SetCursorPos(pos.x, pos.y); - ShowCursor(false); } else { - ShowCursor(true); ReleaseCapture(); ClipCursor(NULL); } + if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) { + hCursor = SetCursor(NULL); + } else { + SetCursor(hCursor); + } } OS_Windows::MouseMode OS_Windows::get_mouse_mode() const{ @@ -1758,7 +1772,7 @@ void OS_Windows::print_error(const char* p_function, const char* p_file, int p_l case ERR_ERROR: print("ERROR: "); break; case ERR_WARNING: print("WARNING: "); break; case ERR_SCRIPT: print("SCRIPT ERROR: "); break; - case ERR_SCRIPT: print("SHADER ERROR: "); break; + case ERR_SHADER: print("SHADER ERROR: "); break; } SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY); @@ -2395,7 +2409,7 @@ void OS_Windows::set_use_vsync(bool p_enable) { gl_context->set_use_vsync(p_enable); } -bool OS_Windows::is_vsnc_enabled() const{ +bool OS_Windows::is_vsync_enabled() const{ if (gl_context) return gl_context->is_using_vsync(); @@ -2428,6 +2442,9 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { #ifdef RTAUDIO_ENABLED AudioDriverManagerSW::add_driver(&driver_rtaudio); #endif +#ifdef XAUDIO2_ENABLED + AudioDriverManagerSW::add_driver(&driver_xaudio2); +#endif } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 70ef694957..19367c758b 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -41,6 +41,9 @@ #include "servers/audio/audio_server_sw.h" #include "servers/audio/sample_manager_sw.h" #include "drivers/rtaudio/audio_driver_rtaudio.h" +#ifdef XAUDIO2_ENABLED +#include "drivers/xaudio2/audio_driver_xaudio2.h" +#endif #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" #include "drivers/unix/ip_unix.h" @@ -92,7 +95,7 @@ class OS_Windows : public OS { int old_x,old_y; Point2i center; unsigned int last_id; -#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) || defined(GLES2_ENABLED) +#if defined(OPENGL_ENABLED) ContextGL_Win *gl_context; #endif VisualServer *visual_server; @@ -137,6 +140,9 @@ class OS_Windows : public OS { #ifdef RTAUDIO_ENABLED AudioDriverRtAudio driver_rtaudio; #endif +#ifdef XAUDIO2_ENABLED + AudioDriverXAudio2 driver_xaudio2; +#endif void _drag_event(int p_x, int p_y, int idx); void _touch_event(bool p_pressed, int p_x, int p_y, int idx); @@ -289,7 +295,7 @@ public: virtual String get_joy_guid(int p_device) const; virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp index 2c79365c08..ef497c428d 100644 --- a/platform/windows/packet_peer_udp_winsock.cpp +++ b/platform/windows/packet_peer_udp_winsock.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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,6 +29,9 @@ #include "packet_peer_udp_winsock.h" #include <winsock2.h> +#include <ws2tcpip.h> + +#include "drivers/unix/socket_helpers.h" int PacketPeerUDPWinsock::get_available_packet_count() const { @@ -48,7 +51,17 @@ Error PacketPeerUDPWinsock::get_packet(const uint8_t **r_buffer,int &r_buffer_si return ERR_UNAVAILABLE; uint32_t size; - rb.read((uint8_t*)&packet_ip.host,4,true); + uint8_t type; + rb.read(&type, 1, true); + if (type == IP::TYPE_IPV4) { + uint8_t ip[4]; + rb.read(ip,4,true); + packet_ip.set_ipv4(ip); + } else { + uint8_t ip[16]; + rb.read(ip,16,true); + packet_ip.set_ipv6(ip); + }; rb.read((uint8_t*)&packet_port,4,true); rb.read((uint8_t*)&size,4,true); rb.read(packet_buffer,size,true); @@ -62,17 +75,14 @@ Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer,int p_buffer_size int sock = _get_socket(); ERR_FAIL_COND_V( sock == -1, FAILED ); - struct sockaddr_in addr; - addr.sin_family = AF_INET; - addr.sin_port = htons(peer_port); - addr.sin_addr = *((struct in_addr*)&peer_addr.host); - + struct sockaddr_storage addr; + size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, ip_type); _set_blocking(true); errno = 0; int err; - while ( (err = sendto(sock, (const char*)p_buffer, p_buffer_size, 0, (struct sockaddr*)&addr, sizeof(addr))) != p_buffer_size) { + while ( (err = sendto(sock, (const char*)p_buffer, p_buffer_size, 0, (struct sockaddr*)&addr, addr_size)) != p_buffer_size) { if (WSAGetLastError() != WSAEWOULDBLOCK) { return FAILED; @@ -104,17 +114,17 @@ void PacketPeerUDPWinsock::_set_blocking(bool p_blocking) { }; } -Error PacketPeerUDPWinsock::listen(int p_port, int p_recv_buffer_size){ +Error PacketPeerUDPWinsock::listen(int p_port, int p_recv_buffer_size) { close(); int sock = _get_socket(); if (sock == -1 ) return ERR_CANT_CREATE; - sockaddr_in addr = {0}; - addr.sin_family = AF_INET; - addr.sin_port = htons(p_port); - addr.sin_addr.s_addr = INADDR_ANY; - if (bind(sock, (struct sockaddr*)&addr, sizeof(sockaddr_in)) == -1 ) { + + struct sockaddr_storage addr = {0}; + size_t addr_size = _set_listen_sockaddr(&addr, p_port, ip_type, NULL); + + if (bind(sock, (struct sockaddr*)&addr, addr_size) == -1 ) { close(); return ERR_UNAVAILABLE; } @@ -146,17 +156,41 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) { _set_blocking(p_wait); - struct sockaddr_in from = {0}; - int len = sizeof(struct sockaddr_in); + struct sockaddr_storage from = {0}; + int len = sizeof(struct sockaddr_storage); int ret; while ( (ret = recvfrom(sockfd, (char*)recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), 0, (struct sockaddr*)&from, &len)) > 0) { - rb.write((uint8_t*)&from.sin_addr, 4); - uint32_t port = ntohs(from.sin_port); + + uint32_t port = 0; + + if (from.ss_family == AF_INET) { + uint8_t type = (uint8_t)IP::TYPE_IPV4; + rb.write(&type, 1); + struct sockaddr_in* sin_from = (struct sockaddr_in*)&from; + rb.write((uint8_t*)&sin_from->sin_addr, 4); + port = ntohs(sin_from->sin_port); + + } else if (from.ss_family == AF_INET6) { + + uint8_t type = (uint8_t)IP::TYPE_IPV6; + rb.write(&type, 1); + + struct sockaddr_in6* s6_from = (struct sockaddr_in6*)&from; + rb.write((uint8_t*)&s6_from->sin6_addr, 16); + + port = ntohs(s6_from->sin6_port); + + } else { + // WARN_PRINT("Ignoring packet with unknown address family"); + uint8_t type = (uint8_t)IP::TYPE_NONE; + rb.write(&type, 1); + }; + rb.write((uint8_t*)&port, 4); rb.write((uint8_t*)&ret, 4); rb.write(recv_buffer, ret); - len = sizeof(struct sockaddr_in); + len = sizeof(struct sockaddr_storage); ++queue_count; }; @@ -207,9 +241,7 @@ int PacketPeerUDPWinsock::_get_socket() { if (sockfd != -1) return sockfd; - sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - ERR_FAIL_COND_V( sockfd == -1, -1 ); - //fcntl(sockfd, F_SETFL, O_NONBLOCK); + sockfd = _socket_create(ip_type, SOCK_DGRAM, IPPROTO_UDP); return sockfd; } @@ -239,6 +271,7 @@ PacketPeerUDPWinsock::PacketPeerUDPWinsock() { packet_port=0; queue_count=0; peer_port=0; + ip_type = IP::TYPE_ANY; } PacketPeerUDPWinsock::~PacketPeerUDPWinsock() { diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h index b24dbac592..2199115889 100644 --- a/platform/windows/packet_peer_udp_winsock.h +++ b/platform/windows/packet_peer_udp_winsock.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -42,8 +42,8 @@ class PacketPeerUDPWinsock : public PacketPeerUDP { mutable RingBuffer<uint8_t> rb; uint8_t recv_buffer[PACKET_BUFFER_SIZE]; mutable uint8_t packet_buffer[PACKET_BUFFER_SIZE]; - IP_Address packet_ip; - int packet_port; + mutable IP_Address packet_ip; + mutable int packet_port; mutable int queue_count; int sockfd; @@ -67,7 +67,7 @@ public: virtual int get_max_packet_size() const; - virtual Error listen(int p_port,int p_recv_buffer_size=65536); + virtual Error listen(int p_port, int p_recv_buffer_size=65536); virtual void close(); virtual Error wait(); virtual bool is_listening() const; diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h index 296a778ac8..19885c4afb 100644 --- a/platform/windows/platform_config.h +++ b/platform/windows/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -30,7 +30,5 @@ //#else //#include <alloca.h> //#endif -#define GLES2_INCLUDE_H "gl_context/GL/glew.h" -#define GLES3_INCLUDE_H "gl_context/GL/glew.h" - - +//#define GLES2_INCLUDE_H "GL/glew.h" +#define GLES3_INCLUDE_H "gl_context/glad/glad.h" diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index fcf0cb1640..a48a02c7a7 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -31,16 +31,11 @@ #include "stream_peer_winsock.h" #include <winsock2.h> +#include <ws2tcpip.h> -int winsock_refcount = 0; - -static void set_addr_in(struct sockaddr_in& their_addr, const IP_Address& p_host, uint16_t p_port) { +#include "drivers/unix/socket_helpers.h" - their_addr.sin_family = AF_INET; // host byte order - their_addr.sin_port = htons(p_port); // short, network byte order - their_addr.sin_addr = *((struct in_addr*)&p_host.host); - memset(&(their_addr.sin_zero), '\0', 8); -}; +int winsock_refcount = 0; StreamPeerTCP* StreamPeerWinsock::_create() { @@ -92,10 +87,10 @@ Error StreamPeerWinsock::_poll_connection(bool p_block) const { _block(sockfd, false, true); }; - struct sockaddr_in their_addr; - set_addr_in(their_addr, peer_host, peer_port); + struct sockaddr_storage their_addr; + size_t addr_size = _set_sockaddr(&their_addr, peer_host, peer_port, ip_type); - if (::connect(sockfd, (struct sockaddr *)&their_addr,sizeof(struct sockaddr)) == SOCKET_ERROR) { + if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == SOCKET_ERROR) { int err = WSAGetLastError(); if (err == WSAEISCONN) { @@ -103,7 +98,12 @@ Error StreamPeerWinsock::_poll_connection(bool p_block) const { return OK; }; - return OK; + if (errno == WSAEINPROGRESS || errno == WSAEALREADY) { + return OK; + } + + status = STATUS_ERROR; + return ERR_CONNECTION_ERROR; } else { status = STATUS_CONNECTED; @@ -289,8 +289,9 @@ void StreamPeerWinsock::disconnect() { peer_port = 0; }; -void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port) { +void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type) { + ip_type = p_ip_type; sockfd = p_sockfd; status = STATUS_CONNECTING; peer_host = p_host; @@ -299,9 +300,10 @@ void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port) Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) { - ERR_FAIL_COND_V( p_host.host == 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V( p_host == IP_Address(), ERR_INVALID_PARAMETER); - if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { + sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP); + if (sockfd == INVALID_SOCKET) { ERR_PRINT("Socket creation failed!"); disconnect(); //perror("socket"); @@ -315,10 +317,10 @@ Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) { return FAILED; }; - struct sockaddr_in their_addr; - set_addr_in(their_addr, p_host, p_port); + struct sockaddr_storage their_addr; + size_t addr_size = _set_sockaddr(&their_addr, p_host, p_port, ip_type); - if (::connect(sockfd, (struct sockaddr *)&their_addr,sizeof(struct sockaddr)) == SOCKET_ERROR) { + if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == SOCKET_ERROR) { if (WSAGetLastError() != WSAEWOULDBLOCK) { ERR_PRINT("Connection to remote host failed!"); @@ -366,6 +368,7 @@ StreamPeerWinsock::StreamPeerWinsock() { sockfd = INVALID_SOCKET; status = STATUS_NONE; peer_port = 0; + ip_type = IP::TYPE_ANY; }; StreamPeerWinsock::~StreamPeerWinsock() { diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h index bbff661490..e17a7167e1 100644 --- a/platform/windows/stream_peer_winsock.h +++ b/platform/windows/stream_peer_winsock.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -68,7 +68,7 @@ public: virtual int get_available_bytes() const; - void set_socket(int p_sockfd, IP_Address p_host, int p_port); + void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type); virtual IP_Address get_connected_host() const; virtual uint16_t get_connected_port() const; diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp index dd1cf43f3b..1c3682adfa 100644 --- a/platform/windows/tcp_server_winsock.cpp +++ b/platform/windows/tcp_server_winsock.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -31,6 +31,9 @@ #include "stream_peer_winsock.h" #include <winsock2.h> +#include <ws2tcpip.h> + +#include "drivers/unix/socket_helpers.h" extern int winsock_refcount; @@ -63,7 +66,7 @@ void TCPServerWinsock::cleanup() { Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_hosts) { int sockfd; - sockfd = socket(AF_INET, SOCK_STREAM, 0); + sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP); ERR_FAIL_COND_V(sockfd == INVALID_SOCKET, FAILED); unsigned long par = 1; @@ -73,11 +76,8 @@ Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_ho return FAILED; }; - struct sockaddr_in my_addr; - my_addr.sin_family = AF_INET; // host byte order - my_addr.sin_port = htons(p_port); // short, network byte order - my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP TODO: use p_accepted_hosts - memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero); + struct sockaddr_storage my_addr; + size_t addr_size = _set_listen_sockaddr(&my_addr, p_port, ip_type, p_accepted_hosts); int reuse=1; if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) < 0) { @@ -86,7 +86,7 @@ Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_ho } - if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) != SOCKET_ERROR) { + if (bind(sockfd, (struct sockaddr *)&my_addr, addr_size) != SOCKET_ERROR) { if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) { @@ -140,16 +140,17 @@ Ref<StreamPeerTCP> TCPServerWinsock::take_connection() { return NULL; }; - struct sockaddr_in their_addr; + struct sockaddr_storage their_addr; int sin_size = sizeof(their_addr); int fd = accept(listen_sockfd, (struct sockaddr *)&their_addr, &sin_size); ERR_FAIL_COND_V(fd == INVALID_SOCKET, NULL); Ref<StreamPeerWinsock> conn = memnew(StreamPeerWinsock); IP_Address ip; - ip.host = (uint32_t)their_addr.sin_addr.s_addr; + int port; + _set_ip_addr_port(ip, port, &their_addr); - conn->set_socket(fd, ip, ntohs(their_addr.sin_port)); + conn->set_socket(fd, ip, port, ip_type); return conn; }; @@ -167,6 +168,7 @@ void TCPServerWinsock::stop() { TCPServerWinsock::TCPServerWinsock() { listen_sockfd = INVALID_SOCKET; + ip_type = IP::TYPE_ANY; }; TCPServerWinsock::~TCPServerWinsock() { diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h index bd6a05c74d..5c544436a7 100644 --- a/platform/windows/tcp_server_winsock.h +++ b/platform/windows/tcp_server_winsock.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/winrt/SCsub b/platform/winrt/SCsub deleted file mode 100644 index fde0c11f3b..0000000000 --- a/platform/winrt/SCsub +++ /dev/null @@ -1,22 +0,0 @@ -Import('env') - -files = [ - 'thread_winrt.cpp', - '#platform/windows/tcp_server_winsock.cpp', - '#platform/windows/packet_peer_udp_winsock.cpp', - '#platform/windows/stream_peer_winsock.cpp', - '#platform/windows/key_mapping_win.cpp', - 'joystick_winrt.cpp', - 'gl_context_egl.cpp', - 'audio_driver_winrt.cpp', - 'app.cpp', - 'os_winrt.cpp', -] - -if "build_angle" in env and env["build_angle"]: - cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None)) - -prog = env.Program('#bin/godot', files) - -if "build_angle" in env and env["build_angle"]: - env.Depends(prog, [cmd]) diff --git a/platform/winrt/audio_driver_winrt.cpp b/platform/winrt/audio_driver_winrt.cpp deleted file mode 100644 index ff46244ac3..0000000000 --- a/platform/winrt/audio_driver_winrt.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/*************************************************************************/ -/* audio_driver_winrt.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 "audio_driver_winrt.h" - -#include "globals.h" -#include "os/os.h" - -using namespace Windows::Media; -using namespace Windows::Media::Core; -using namespace Windows::Media::MediaProperties; -using namespace Windows::Media::Editing; -using namespace Windows::Foundation; - -const char * AudioDriverWinRT::get_name() const -{ - return "WinRT"; -} - -Error AudioDriverWinRT::init() { - - active = false; - thread_exited = false; - exit_thread = false; - pcm_open = false; - samples_in = NULL; - - - mix_rate = 48000; - output_format = OUTPUT_STEREO; - channels = 2; - - int latency = GLOBAL_DEF("audio/output_latency", 25); - buffer_size = nearest_power_of_2(latency * mix_rate / 1000); - - samples_in = memnew_arr(int32_t, buffer_size*channels); - for (int i = 0; i < AUDIO_BUFFERS; i++) { - samples_out[i] = memnew_arr(int16_t, buffer_size*channels); - xaudio_buffer[i].AudioBytes = buffer_size * channels * sizeof(int16_t); - xaudio_buffer[i].pAudioData = (const BYTE*)(samples_out[i]); - xaudio_buffer[i].Flags = 0; - } - - HRESULT hr; - hr = XAudio2Create(&xaudio, 0, XAUDIO2_DEFAULT_PROCESSOR); - if (hr != S_OK) { - ERR_EXPLAIN("Error creating XAudio2 engine."); - ERR_FAIL_V(ERR_UNAVAILABLE); - } - hr = xaudio->CreateMasteringVoice(&mastering_voice); - if (hr != S_OK) { - ERR_EXPLAIN("Error creating XAudio2 mastering voice."); - ERR_FAIL_V(ERR_UNAVAILABLE); - } - - wave_format.nChannels = channels; - wave_format.cbSize = 0; - wave_format.nSamplesPerSec = mix_rate; - wave_format.wFormatTag = WAVE_FORMAT_PCM; - wave_format.wBitsPerSample = 16; - wave_format.nBlockAlign = channels * wave_format.wBitsPerSample >> 3; - wave_format.nAvgBytesPerSec = mix_rate * wave_format.nBlockAlign; - - voice_callback = memnew(XAudio2DriverVoiceCallback); - - hr = xaudio->CreateSourceVoice(&source_voice, &wave_format, 0, XAUDIO2_MAX_FREQ_RATIO, voice_callback); - if (hr != S_OK) { - ERR_EXPLAIN("Error creating XAudio2 source voice. " + itos(hr)); - ERR_FAIL_V(ERR_UNAVAILABLE); - } - - mutex = Mutex::create(); - thread = Thread::create(AudioDriverWinRT::thread_func, this); - - return OK; -}; - -void AudioDriverWinRT::thread_func(void* p_udata) { - - AudioDriverWinRT* ad = (AudioDriverWinRT*)p_udata; - - uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000; - - while (!ad->exit_thread) { - - - if (!ad->active) { - - for (int i = 0; i < AUDIO_BUFFERS; i++) { - ad->xaudio_buffer[i].Flags = XAUDIO2_END_OF_STREAM; - } - - } else { - - ad->lock(); - - ad->audio_server_process(ad->buffer_size, ad->samples_in); - - ad->unlock(); - - for (unsigned int i = 0;i < ad->buffer_size*ad->channels;i++) { - - ad->samples_out[ad->current_buffer][i] = ad->samples_in[i] >> 16; - } - - ad->xaudio_buffer[ad->current_buffer].Flags = 0; - ad->xaudio_buffer[ad->current_buffer].AudioBytes = ad->buffer_size * ad->channels * sizeof(int16_t); - ad->xaudio_buffer[ad->current_buffer].pAudioData = (const BYTE*)(ad->samples_out[ad->current_buffer]); - ad->xaudio_buffer[ad->current_buffer].PlayBegin = 0; - ad->source_voice->SubmitSourceBuffer(&(ad->xaudio_buffer[ad->current_buffer])); - - ad->current_buffer = (ad->current_buffer + 1) % AUDIO_BUFFERS; - - XAUDIO2_VOICE_STATE state; - while (ad->source_voice->GetState(&state), state.BuffersQueued > AUDIO_BUFFERS - 1) - { - WaitForSingleObject(ad->voice_callback->buffer_end_event, INFINITE); - } - } - - }; - - ad->thread_exited = true; - -}; - -void AudioDriverWinRT::start() { - - active = true; - HRESULT hr = source_voice->Start(0); - if (hr != S_OK) { - ERR_EXPLAIN("XAudio2 start error " + itos(hr)); - ERR_FAIL(); - } -}; - -int AudioDriverWinRT::get_mix_rate() const { - - return mix_rate; -}; - -AudioDriverSW::OutputFormat AudioDriverWinRT::get_output_format() const { - - return output_format; -}; - -float AudioDriverWinRT::get_latency() { - - XAUDIO2_PERFORMANCE_DATA perf_data; - xaudio->GetPerformanceData(&perf_data); - if (perf_data.CurrentLatencyInSamples) { - return (float)(perf_data.CurrentLatencyInSamples / ((float)mix_rate)); - } else { - return 0; - } -} - -void AudioDriverWinRT::lock() { - - if (!thread || !mutex) - return; - mutex->lock(); -}; -void AudioDriverWinRT::unlock() { - - if (!thread || !mutex) - return; - mutex->unlock(); -}; - -void AudioDriverWinRT::finish() { - - if (!thread) - return; - - exit_thread = true; - Thread::wait_to_finish(thread); - - if (source_voice) { - source_voice->Stop(0); - memdelete(source_voice); - } - - if (samples_in) { - memdelete_arr(samples_in); - }; - if (samples_out[0]) { - for (int i = 0; i < AUDIO_BUFFERS; i++) { - memdelete_arr(samples_out[i]); - } - }; - - memdelete(voice_callback); - memdelete(mastering_voice); - - memdelete(thread); - if (mutex) - memdelete(mutex); - thread = NULL; -}; - -AudioDriverWinRT::AudioDriverWinRT() { - - mutex = NULL; - thread = NULL; - wave_format = { 0 }; - for (int i = 0; i < AUDIO_BUFFERS; i++) { - xaudio_buffer[i] = { 0 }; - samples_out[i] = 0; - } - current_buffer = 0; -}; - -AudioDriverWinRT::~AudioDriverWinRT() { - - -}; - - diff --git a/platform/winrt/audio_driver_winrt.h b/platform/winrt/audio_driver_winrt.h deleted file mode 100644 index d7a69994f8..0000000000 --- a/platform/winrt/audio_driver_winrt.h +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************/ -/* audio_driver_winrt.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 AUDIO_DRIVER_WINRT_H -#define AUDIO_DRIVER_WINRT_H - -#include "servers/audio/audio_server_sw.h" - -#include "core/os/thread.h" -#include "core/os/mutex.h" - -#include <windows.h> -#include <mmsystem.h> -#include <mmreg.h> -#include <xaudio2.h> -#include <wrl/client.h> - -class AudioDriverWinRT : public AudioDriverSW { - - enum { - AUDIO_BUFFERS = 2 - }; - - struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback { - - HANDLE buffer_end_event; - XAudio2DriverVoiceCallback() : buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {} - void STDMETHODCALLTYPE OnBufferEnd(void* pBufferContext) { /*print_line("buffer ended");*/ SetEvent(buffer_end_event); } - - //Unused methods are stubs - void STDMETHODCALLTYPE OnStreamEnd() { } - void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() { } - void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) { } - void STDMETHODCALLTYPE OnBufferStart(void * pBufferContext) { } - void STDMETHODCALLTYPE OnLoopEnd(void * pBufferContext) { } - void STDMETHODCALLTYPE OnVoiceError(void * pBufferContext, HRESULT Error) { } - - }; - - Thread* thread; - Mutex* mutex; - - int32_t* samples_in; - int16_t* samples_out[AUDIO_BUFFERS]; - - static void thread_func(void* p_udata); - int buffer_size; - - unsigned int mix_rate; - OutputFormat output_format; - - int channels; - - bool active; - bool thread_exited; - mutable bool exit_thread; - bool pcm_open; - - WAVEFORMATEX wave_format; - Microsoft::WRL::ComPtr<IXAudio2> xaudio; - int current_buffer; - IXAudio2MasteringVoice* mastering_voice; - XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS]; - IXAudio2SourceVoice* source_voice; - XAudio2DriverVoiceCallback* voice_callback; - -public: - - const char* get_name() const; - - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual OutputFormat get_output_format() const; - virtual float get_latency(); - virtual void lock(); - virtual void unlock(); - virtual void finish(); - - AudioDriverWinRT(); - ~AudioDriverWinRT(); -}; - -#endif diff --git a/platform/winrt/detect.py b/platform/winrt/detect.py deleted file mode 100644 index 7f220736d7..0000000000 --- a/platform/winrt/detect.py +++ /dev/null @@ -1,165 +0,0 @@ -import os - -import sys -import string -import methods - - -def is_active(): - return True - -def get_name(): - return "WinRT" - -def can_build(): - if (os.name=="nt"): - #building natively on windows! - if (os.getenv("VSINSTALLDIR")): - - if (os.getenv("ANGLE_SRC_PATH") == None): - return False - - return True - return False - -def get_opts(): - return [] - -def get_flags(): - - return [ - ('tools', 'no'), - ('openssl', 'builtin'), - ] - - -def configure(env): - - if(env["bits"] != "default"): - print "Error: bits argument is disabled for MSVC" - print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" - +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=winrt) and SCons will attempt to detect what MSVC compiler" - +" will be executed and inform you.") - sys.exit() - - arch = "" - env['ENV'] = os.environ; - - # ANGLE - angle_root = os.getenv("ANGLE_SRC_PATH") - env.Append(CPPPATH=[angle_root + '/include']) - jobs = str(env.GetOption("num_jobs")) - angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform=" - - if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): - env["build_angle"] = True - - if os.getenv('Platform') == "ARM": - - print "Compiled program architecture will be an ARM executable. (forcing bits=32)." - - arch="arm" - env["bits"]="32" - env.Append(LINKFLAGS=['/MACHINE:ARM']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm']) - - angle_build_cmd += "ARM" - - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) - - else: - - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) - - if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): - env["bits"]="64" - print "Compiled program architecture will be a x64 executable (forcing bits=64)." - elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"): - env["bits"]="32" - print "Compiled program architecture will be a x86 executable. (forcing bits=32)." - else: - print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." - env["bits"]="32" - - if (env["bits"] == "32"): - arch = "x86" - - angle_build_cmd += "Win32" - - env.Append(CPPFLAGS=['/DPNG_ABORT=abort']) - env.Append(LINKFLAGS=['/MACHINE:X86']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store']) - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib']) - - else: - arch = "x64" - - angle_build_cmd += "x64" - - env.Append(LINKFLAGS=['/MACHINE:X64']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64']) - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib']) - - env.Append(CPPPATH=['#platform/winrt','#drivers/windows']) - env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"']) - env.Append(CPPFLAGS=['/D','__WRL_NO_DEFAULT_LIB__','/D','WIN32']) - env.Append(CPPFLAGS=['/FU', os.environ['VCINSTALLDIR'] + 'lib/store/references/platform.winmd']) - env.Append(CPPFLAGS=['/AI', os.environ['VCINSTALLDIR'] + 'lib/store/references']) - - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/references']) - - if (env["target"]=="release"): - - env.Append(CPPFLAGS=['/O2', '/GL']) - env.Append(CPPFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['/O2','/Zi','/DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED']) - env.Append(CPPFLAGS=['/MDd']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/DEBUG']) - - - env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo')) - env.Append(CXXFLAGS=string.split('/ZW /FS')) - env.Append(CCFLAGS=['/AI', os.environ['VCINSTALLDIR']+'\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR']+'\\References\\CommonConfiguration\\Neutral']) - - - env["PROGSUFFIX"]="."+arch+env["PROGSUFFIX"] - env["OBJSUFFIX"]="."+arch+env["OBJSUFFIX"] - env["LIBSUFFIX"]="."+arch+env["LIBSUFFIX"] - - env.Append(CCFLAGS=['/DWINRT_ENABLED']) - env.Append(CCFLAGS=['/DWINDOWS_ENABLED']) - env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) - - env.Append(CCFLAGS=['/DGLES2_ENABLED','/DGL_GLEXT_PROTOTYPES','/DEGL_EGLEXT_PROTOTYPES','/DANGLE_ENABLED']) - - LIBS = [ - 'xaudio2', - 'WindowsApp', - 'mincore', - 'libANGLE', - 'libEGL', - 'libGLESv2', - ] - env.Append(LINKFLAGS=[p+".lib" for p in LIBS]) - - # Incremental linking fix - env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] - env['BUILDERS']['Program'] = methods.precious_program - - env.Append( BUILDERS = { 'ANGLE' : env.Builder(action = angle_build_cmd) } ) - - env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_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.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) diff --git a/platform/x11/SCsub b/platform/x11/SCsub index 80fd347ded..0defd4f025 100644 --- a/platform/x11/SCsub +++ b/platform/x11/SCsub @@ -1,11 +1,13 @@ +#!/usr/bin/env python + Import('env') -common_x11=[\ - "context_gl_x11.cpp",\ - "os_x11.cpp",\ - "key_mapping_x11.cpp",\ - "joystick_linux.cpp",\ +common_x11 = [\ + "context_gl_x11.cpp",\ + "os_x11.cpp",\ + "key_mapping_x11.cpp",\ + "joystick_linux.cpp",\ ] -env.Program('#bin/godot',['godot_x11.cpp']+common_x11) +env.Program('#bin/godot', ['godot_x11.cpp'] + common_x11) diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index ccf7a801ef..4adb47938c 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -76,6 +76,13 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { }*/ +static bool ctxErrorOccurred = false; +static int ctxErrorHandler( Display *dpy, XErrorEvent *ev ) +{ + ctxErrorOccurred = true; + return 0; +} + Error ContextGL_X11::initialize() { @@ -133,21 +140,31 @@ Error ContextGL_X11::initialize() { //}; + int (*oldHandler)(Display*, XErrorEvent*) = + XSetErrorHandler(&ctxErrorHandler); + + if (!opengl_3_context) { //oldstyle context: p->glx_context = glXCreateContext(x11_display, vi, 0, GL_TRUE); } else { static int context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - GLX_CONTEXT_MINOR_VERSION_ARB, 0, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB/*|GLX_CONTEXT_DEBUG_BIT_ARB*/, None }; p->glx_context = glXCreateContextAttribsARB(x11_display, fbc[0], NULL, true, context_attribs); - ERR_FAIL_COND_V(!p->glx_context,ERR_UNCONFIGURED); + ERR_EXPLAIN("Could not obtain an OpenGL 3.3 context!"); + ERR_FAIL_COND_V(ctxErrorOccurred || !p->glx_context,ERR_UNCONFIGURED); } + XSync( x11_display, False ); + XSetErrorHandler( oldHandler ); + + print_line("ALL IS GOOD"); + glXMakeCurrent(x11_display, x11_window, p->glx_context); /* diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h index 4474542c0b..efe377ad92 100644 --- a/platform/x11/context_gl_x11.h +++ b/platform/x11/context_gl_x11.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/detect.py b/platform/x11/detect.py index 6e3a8af676..19884feaa8 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -5,208 +5,233 @@ import platform def is_active(): - return True + return True + def get_name(): - return "X11" + return "X11" def can_build(): - if (os.name!="posix"): - return False + if (os.name != "posix"): + return False - if sys.platform == "darwin": - return False # no x11 on mac for now + if sys.platform == "darwin": + return False # no x11 on mac for now - errorval=os.system("pkg-config --version > /dev/null") + errorval = os.system("pkg-config --version > /dev/null") - if (errorval): - print("pkg-config not found.. x11 disabled.") - return False + if (errorval): + print("pkg-config not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config x11 --modversion > /dev/null ") - if (x11_error): - print("X11 not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config x11 --modversion > /dev/null ") + if (x11_error): + print("X11 not found.. x11 disabled.") + return False - ssl_error=os.system("pkg-config openssl --modversion > /dev/null ") - if (ssl_error): - print("OpenSSL not found.. x11 disabled.") - return False + ssl_error = os.system("pkg-config openssl --modversion > /dev/null ") + if (ssl_error): + print("OpenSSL not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config xcursor --modversion > /dev/null ") - if (x11_error): - print("xcursor not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config xcursor --modversion > /dev/null ") + if (x11_error): + print("xcursor not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config xinerama --modversion > /dev/null ") - if (x11_error): - print("xinerama not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config xinerama --modversion > /dev/null ") + if (x11_error): + print("xinerama not found.. x11 disabled.") + return False - x11_error=os.system("pkg-config xrandr --modversion > /dev/null ") - if (x11_error): - print("xrandr not found.. x11 disabled.") - return False + x11_error = os.system("pkg-config xrandr --modversion > /dev/null ") + if (x11_error): + print("xrandr not found.. x11 disabled.") + return False + return True # X11 enabled - return True # X11 enabled def get_opts(): - return [ - ('use_llvm','Use llvm compiler','no'), - ('use_static_cpp','link stdc++ statically','no'), - ('use_sanitizer','Use llvm compiler sanitize address','no'), - ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'), - ('pulseaudio','Detect & Use pulseaudio','yes'), - ('udev','Use udev for gamepad connection callbacks','no'), - ('debug_release', 'Add debug symbols to release version','no'), - ] - -def get_flags(): + return [ + ('use_llvm', 'Use llvm compiler', 'no'), + ('use_static_cpp', 'link stdc++ statically', 'no'), + ('use_sanitizer', 'Use llvm compiler sanitize address', 'no'), + ('use_leak_sanitizer', 'Use llvm compiler sanitize memory leaks', 'no'), + ('pulseaudio', 'Detect & Use pulseaudio', 'yes'), + ('udev', 'Use udev for gamepad connection callbacks', 'no'), + ('debug_release', 'Add debug symbols to release version', 'no'), + ] - return [ - ('builtin_zlib', 'no'), - ('glew', 'yes'), - ("openssl", "yes"), - ('freetype','yes'), #use system freetype - #("theora","no"), - ] +def get_flags(): + return [ + ('builtin_freetype', 'no'), + ('builtin_libpng', 'no'), + ('builtin_openssl', 'no'), + ('builtin_zlib', 'no'), + ] def configure(env): - is64=sys.maxsize > 2**32 - - if (env["bits"]=="default"): - if (is64): - env["bits"]="64" - else: - env["bits"]="32" - - env.Append(CPPPATH=['#platform/x11']) - if (env["use_llvm"]=="yes"): - if 'clang++' not in env['CXX']: - env["CC"]="clang" - env["CXX"]="clang++" - env["LD"]="clang++" - env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) - env.extra_suffix=".llvm" - - if (env["colored"]=="yes"): - if sys.stdout.isatty(): - env.Append(CXXFLAGS=["-fcolor-diagnostics"]) - - if (env["use_sanitizer"]=="yes"): - env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) - env.Append(LINKFLAGS=['-fsanitize=address']) - env.extra_suffix+="s" - - if (env["use_leak_sanitizer"]=="yes"): - env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer']) - env.Append(LINKFLAGS=['-fsanitize=address']) - env.extra_suffix+="s" - - - #if (env["tools"]=="no"): - # #no tools suffix - # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] - # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] - - - if (env["target"]=="release"): - - if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2']) - else: - env.Append(CCFLAGS=['-O3','-ffast-math']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED']) - if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2']) - - elif (env["target"]=="debug"): - - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - - env.ParseConfig('pkg-config x11 --cflags --libs') - env.ParseConfig('pkg-config xinerama --cflags --libs') - env.ParseConfig('pkg-config xcursor --cflags --libs') - env.ParseConfig('pkg-config xrandr --cflags --libs') - - if (env["openssl"]=="yes"): - env.ParseConfig('pkg-config openssl --cflags --libs') - - - if (env["freetype"]=="yes"): - env.ParseConfig('pkg-config freetype2 --cflags --libs') - - - + is64 = sys.maxsize > 2**32 - env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) + if (env["bits"] == "default"): + if (is64): + env["bits"] = "64" + else: + env["bits"] = "32" - if os.system("pkg-config --exists alsa")==0: - print("Enabling ALSA") - env.Append(CPPFLAGS=["-DALSA_ENABLED"]) - env.ParseConfig('pkg-config alsa --cflags --libs') - else: - print("ALSA libraries not found, disabling driver") + env.Append(CPPPATH=['#platform/x11']) + if (env["use_llvm"] == "yes"): + if 'clang++' not in env['CXX']: + env["CC"] = "clang" + env["CXX"] = "clang++" + env["LD"] = "clang++" + env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) + env.extra_suffix = ".llvm" - if (platform.system() == "Linux"): - env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) - if (env["udev"]=="yes"): - # pkg-config returns 0 when the lib exists... - found_udev = not os.system("pkg-config --exists libudev") + if (env["use_sanitizer"] == "yes"): + env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer']) + env.Append(LINKFLAGS=['-fsanitize=address']) + env.extra_suffix += "s" - if (found_udev): - print("Enabling udev support") - env.Append(CPPFLAGS=["-DUDEV_ENABLED"]) - env.ParseConfig('pkg-config libudev --cflags --libs') - else: - print("libudev development libraries not found, disabling udev support") + if (env["use_leak_sanitizer"] == "yes"): + env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer']) + env.Append(LINKFLAGS=['-fsanitize=address']) + env.extra_suffix += "s" - if (env["pulseaudio"]=="yes"): - if not os.system("pkg-config --exists libpulse-simple"): - print("Enabling PulseAudio") - env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"]) - env.ParseConfig('pkg-config --cflags --libs libpulse-simple') - else: - print("PulseAudio development libraries not found, disabling driver") + # if (env["tools"]=="no"): + # #no tools suffix + # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX'] + # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX'] + + if (env["target"] == "release"): - env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'pthread', 'z']) - if (platform.system() == "Linux"): - env.Append(LIBS='dl') - #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) + if (env["debug_release"] == "yes"): + env.Append(CCFLAGS=['-g2']) + else: + env.Append(CCFLAGS=['-O3', '-ffast-math']) + + elif (env["target"] == "release_debug"): + + env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED']) + if (env["debug_release"] == "yes"): + env.Append(CCFLAGS=['-g2']) -#host compiler is default.. + elif (env["target"] == "debug"): + + env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + + env.ParseConfig('pkg-config x11 --cflags --libs') + env.ParseConfig('pkg-config xinerama --cflags --libs') + env.ParseConfig('pkg-config xcursor --cflags --libs') + env.ParseConfig('pkg-config xrandr --cflags --libs') - if (is64 and env["bits"]=="32"): - env.Append(CPPFLAGS=['-m32']) - env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu']) - elif (not is64 and env["bits"]=="64"): - env.Append(CPPFLAGS=['-m64']) - env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu']) + if (env['builtin_openssl'] == 'no'): + env.ParseConfig('pkg-config openssl --cflags --libs') + + if (env['builtin_libwebp'] == 'no'): + env.ParseConfig('pkg-config libwebp --cflags --libs') + + if (env['builtin_freetype'] == 'no'): + env.ParseConfig('pkg-config freetype2 --cflags --libs') + + if (env['builtin_libpng'] == 'no'): + env.ParseConfig('pkg-config libpng --cflags --libs') + + if (env['builtin_enet'] == 'no'): + env.ParseConfig('pkg-config libenet --cflags --libs') + + if (env['builtin_squish'] == 'no' and env["tools"] == "yes"): + env.ParseConfig('pkg-config libsquish --cflags --libs') + + # Sound and video libraries + # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) + + if (env['builtin_libtheora'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system libtheora + env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora + env.ParseConfig('pkg-config theora theoradec --cflags --libs') + + if (env['builtin_libvpx'] == 'no'): + env.ParseConfig('pkg-config vpx --cflags --libs') + + if (env['builtin_libvorbis'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system libvorbis + env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') + + if (env['builtin_opus'] == 'no'): + env['builtin_libogg'] = 'no' # Needed to link against system opus + env.ParseConfig('pkg-config opus opusfile --cflags --libs') + + if (env['builtin_libogg'] == 'no'): + env.ParseConfig('pkg-config ogg --cflags --libs') + + env.Append(CPPFLAGS=['-DOPENGL_ENABLED']) + + if (env['builtin_glew'] == 'no'): + env.ParseConfig('pkg-config glew --cflags --libs') + + if os.system("pkg-config --exists alsa") == 0: + print("Enabling ALSA") + env.Append(CPPFLAGS=["-DALSA_ENABLED"]) + env.ParseConfig('pkg-config alsa --cflags --libs') + else: + print("ALSA libraries not found, disabling driver") + + if (platform.system() == "Linux"): + env.Append(CPPFLAGS=["-DJOYDEV_ENABLED"]) + if (env["udev"] == "yes"): + # pkg-config returns 0 when the lib exists... + found_udev = not os.system("pkg-config --exists libudev") + + if (found_udev): + print("Enabling udev support") + env.Append(CPPFLAGS=["-DUDEV_ENABLED"]) + env.ParseConfig('pkg-config libudev --cflags --libs') + else: + print("libudev development libraries not found, disabling udev support") + if (env["pulseaudio"] == "yes"): + if not os.system("pkg-config --exists libpulse-simple"): + print("Enabling PulseAudio") + env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"]) + env.ParseConfig('pkg-config --cflags --libs libpulse-simple') + else: + print("PulseAudio development libraries not found, disabling driver") - import methods + env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) + env.Append(LIBS=['GL', 'pthread', 'z']) + if (platform.system() == "Linux"): + env.Append(LIBS='dl') + # env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) - #env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - #env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - #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') } ) +# host compiler is default.. - if (env["use_static_cpp"]=="yes"): - env.Append(LINKFLAGS=['-static-libstdc++']) + if (is64 and env["bits"] == "32"): + env.Append(CPPFLAGS=['-m32']) + env.Append(LINKFLAGS=['-m32', '-L/usr/lib/i386-linux-gnu']) + elif (not is64 and env["bits"] == "64"): + env.Append(CPPFLAGS=['-m64']) + env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) - list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] - if any(platform.machine() in s for s in list_of_x86): - env["x86_opt_gcc"]=True + import methods + # FIXME: Commented out when moving to gles3 + #env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) + #env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) + #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') } ) + + if (env["use_static_cpp"] == "yes"): + env.Append(LINKFLAGS=['-static-libstdc++']) + + list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] + if any(platform.machine() in s for s in list_of_x86): + env["x86_libtheora_opt_gcc"] = True diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp index c6675ace72..c1af323453 100644 --- a/platform/x11/export/export.cpp +++ b/platform/x11/export/export.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/export/export.h b/platform/x11/export/export.h index 9dc13d7459..5beaba2cfb 100644 --- a/platform/x11/export/export.h +++ b/platform/x11/export/export.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp index c500f939c4..f85ba17020 100644 --- a/platform/x11/godot_x11.cpp +++ b/platform/x11/godot_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index 3b854a8d46..d101a725ad 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/joystick_linux.h b/platform/x11/joystick_linux.h index 7ea2664ebb..34e7001ca9 100644 --- a/platform/x11/joystick_linux.h +++ b/platform/x11/joystick_linux.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp index 6443d14897..7b92ed95de 100644 --- a/platform/x11/key_mapping_x11.cpp +++ b/platform/x11/key_mapping_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h index e3aede8388..9749b2ec2a 100644 --- a/platform/x11/key_mapping_x11.h +++ b/platform/x11/key_mapping_x11.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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/x11/os_x11.cpp b/platform/x11/os_x11.cpp index d2d6e88c4b..74482a57e7 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -204,7 +204,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) - context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); + context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, true ) ); context_gl->initialize(); RasterizerGLES3::register_config(); @@ -1954,7 +1954,7 @@ void OS_X11::set_use_vsync(bool p_enable) { return context_gl->set_use_vsync(p_enable); } -bool OS_X11::is_vsnc_enabled() const { +bool OS_X11::is_vsync_enabled() const { if (context_gl) return context_gl->is_using_vsync(); @@ -1993,6 +1993,11 @@ OS_X11::OS_X11() { AudioDriverManagerSW::add_driver(&driver_alsa); #endif + if(AudioDriverManagerSW::get_driver_count() == 0){ + WARN_PRINT("No sound driver found... Defaulting to dummy driver"); + AudioDriverManagerSW::add_driver(&driver_dummy); + } + minimized = false; xim_style=0L; mouse_mode=MOUSE_MODE_VISIBLE; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index b351309d80..b89921fb3e 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -44,6 +44,7 @@ #include "drivers/rtaudio/audio_driver_rtaudio.h" #include "drivers/alsa/audio_driver_alsa.h" #include "drivers/pulseaudio/audio_driver_pulseaudio.h" +#include "servers/audio/audio_driver_dummy.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_wrap_mt.h" #include "main/input_default.h" @@ -168,6 +169,7 @@ class OS_X11 : public OS_Unix { #ifdef PULSEAUDIO_ENABLED AudioDriverPulseAudio driver_pulseaudio; #endif + AudioDriverDummy driver_dummy; Atom net_wm_icon; @@ -264,7 +266,7 @@ public: virtual void set_context(int p_context); virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; void run(); diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h index 1873e712ec..74d507f5a2 100644 --- a/platform/x11/platform_config.h +++ b/platform/x11/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,6 @@ #define PTHREAD_BSD_SET_NAME #endif -#define GLES2_INCLUDE_H "gl_context/GL/glew.h" -#define GLES3_INCLUDE_H "gl_context/GL/glew.h" - - +#define GLES2_INCLUDE_H "GL/glew.h" +//#define GLES3_INCLUDE_H "GL/glew.h" +#define GLES3_INCLUDE_H "gl_context/glad/glad.h" |