diff --git a/AUTHORS b/AUTHORS index 0f9ee1b0bf..16bd2643fb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1053,6 +1053,9 @@ Developers: vovkasm Fix warnings for Xcode6.1 + + nilium + Unignore libs dir in plugin and fix Travis script to descend into included directories Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index 8ab6765be2..6ad5b15483 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ -cocos2d-x-3.3 ?? +cocos2d-x-3.3-rc1 ?? [NEW] Vec2: added greater than operator + [NEW] WP8: Win8.1 universal app support [FIX] Audio: `SimpleAudioEngine::sharedEngine()->playBackgroundMusic()` crashed freezen on Lollipop(Android5.0) [FIX] Button: when the dimension of button title is larger than the button, button will scale to fit the dimension of the button title @@ -17,7 +18,7 @@ cocos2d-x-3.3 ?? [FIX] Scale9Sprite: if scale and flip property are set at the same time, the result would be wrong [FIX] Scene: setScale() doesn't work as expected [FIX] Sprite3D: did not create attached sprite from cache - [FIX] WP/WinRT: Windows 8.1 universal app support; `UIEditBox` support + [FIX] WP: back key behaviour and Director::getInstance()->end() works not correctly cocos2d-x-3.3-rc0 Oct.21 2014 [NEW] 3d: added light support: direction light, point light, spot light and ambient light diff --git a/CMakeLists.txt b/CMakeLists.txt index 212ba9f946..7160321934 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,9 +34,20 @@ include(CocosBuildHelpers) message(${BUILDING_STRING}) +set(USE_WEBP_DEFAULT ON) +if(WINRT OR WP8) + set(USE_WEBP_DEFAULT OFF) +endif() + +set(USE_PREBUILT_LIBS_DEFAULT ON) +if(MINGW) + set(USE_PREBUILT_LIBS_DEFAULT OFF) +endif() + option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) -option(BUILD_STATIC "Build static libraries" ON) +option(USE_WEBP "Use WebP codec" ${USE_WEBP_DEFAULT}) +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(DEBUG_MODE "Debug or release?" ON) option(BUILD_EXTENSIONS "Build extension library" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) @@ -45,6 +56,11 @@ option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_CPP_TESTS "Build TestCpp samples" ON) option(BUILD_LUA_LIBS "Build lua libraries" ON) option(BUILD_LUA_TESTS "Build TestLua samples" ON) +option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ${USE_PREBUILT_LIBS_DEFAULT}) + +if(USE_PREBUILT_LIBS AND MINGW) + message(FATAL_ERROR "Prebuilt windows libs can't be used with mingw, please use packages.") +endif() if(DEBUG_MODE) set(CMAKE_BUILD_TYPE DEBUG) @@ -70,22 +86,18 @@ else() endif() endif(MSVC) -if(BUILD_STATIC) - set (BUILD_TYPE STATIC) -else() - set (BUILD_TYPE SHARED) -endif() +set(COCOS_EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) # Some macro definitions if(WINDOWS) - if(BUILD_STATIC) - ADD_DEFINITIONS (-DCC_STATIC) - else() + if(BUILD_SHARED_LIBS) ADD_DEFINITIONS (-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL) + else() + ADD_DEFINITIONS (-DCC_STATIC) endif() - ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32) + ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32) set(PLATFORM_FOLDER win32) elseif(MACOSX OR APPLE) ADD_DEFINITIONS (-DCC_TARGET_OS_MAC) @@ -102,10 +114,8 @@ else() endif() if(MINGW) - add_definitions(-DGLEW_STATIC) + #add_definitions(-DGLEW_STATIC) add_definitions(-D__SSIZE_T) - set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lws2_32") - set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32") if(CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions ") @@ -131,91 +141,138 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external ) -# Specific Link Directories -if(LINUX) - set(PLATFORM_LINK_DIR - /usr/local/lib - ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR} - ) - set(PLATFORM_FOLDER_ARCH - ${PLATFORM_FOLDER}/${ARCH_DIR} - ) -elseif(NOT MINGW) - set(PLATFORM_FOLDER_ARCH ${PLATFORM_FOLDER}) +if(USE_PREBUILT_LIBS) + include(CocosUsePrebuiltLibs) endif() - -# NB -# we need to return these to libraries to their official state rather than -# having our custom cocos2d namespace so that we may use system versions if -# the platform provides them. It is very important that this -# is done before we make prebuilt versions of these two libs - -include_directories( - - ${CMAKE_CURRENT_SOURCE_DIR}/../external/unzip - ${CMAKE_CURRENT_SOURCE_DIR}/../external/xxhash - -) - # GLFW3 used on Mac, Windows and Linux desktop platforms if(LINUX OR MACOSX OR WINDOWS) - list(APPEND CMAKE_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/include/${PLATFORM_FOLDER}) - list(APPEND CMAKE_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER_ARCH}) + cocos_find_package(OpenGL OPENGL REQUIRED) - find_package(GLFW3 REQUIRED) - message( STATUS "GLFW3 dirs: ${GLFW3_INCLUDE_DIRS}") + if(LINUX OR WINDOWS) + cocos_find_package(GLEW GLEW REQUIRED) + endif() + + cocos_find_package(GLFW3 GLFW3 REQUIRED) include_directories(${GLFW3_INCLUDE_DIRS}) + if(LINUX) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + find_package(Threads REQUIRED) + set(THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + + cocos_find_package(FMODEX FMODEX REQUIRED) + cocos_find_package(Fontconfig FONTCONFIG REQUIRED) + endif() + + if(WINDOWS) + cocos_find_package(Vorbis VORBIS REQUIRED) + cocos_find_package(MPG123 MPG123 REQUIRED) + cocos_find_package(OpenAL OPENAL REQUIRED) + # because FindOpenAL.cmake set include dir for '#include ' for portability (not for '#include ' + set(OPENAL_DEFINITIONS "-DOPENAL_PLAIN_INCLUDES") + endif() endif(LINUX OR MACOSX OR WINDOWS) +# Freetype required on all platforms +cocos_find_package(Freetype FREETYPE REQUIRED) -if(NOT MINGW) +# WebP required if used +if(USE_WEBP) + cocos_find_package(WebP WEBP REQUIRED) +endif(USE_WEBP) - include_directories( - - ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2 - ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk - ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/include - ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf-lite/src - ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER}/freetype2 - ) - -#todo: fix location of freetype includes for linux android on cocos prebuilt repo -#i.e we should not need to include an extra dir of /freetype2 - - link_directories( - ${PLATFORM_LINK_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER_ARCH} - - ) +# Chipmunk +if(USE_CHIPMUNK) + cocos_find_package(Chipmunk CHIPMUNK REQUIRED) + add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) + if(IOS OR MACOSX) + # without this chipmunk will try to use apple defined geometry types, that conflicts with cocos + add_definitions(-DCP_USE_CGPOINTS=0) + endif() +else(USE_CHIPMUNK) + add_definitions(-DCC_USE_PHYSICS=0) +endif(USE_CHIPMUNK) +# Box2d (not prebuilded, exists as source) +if(USE_BOX2D) + if(USE_PREBUILT_LIBS) + add_subdirectory(external/Box2D) + set(Box2D_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/include) + set(Box2D_LIBRARIES box2d) + else() + find_package(Box2D REQUIRED CONFIG) + # actually Box2D in next line is not a library, it is target exported from Box2DConfig.cmake + set(Box2D_LIBRARIES Box2D) + endif() + message(STATUS "Box2D include dirs: ${Box2D_INCLUDE_DIRS}") + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1) +else() + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=0) +endif(USE_BOX2D) +# Tinyxml2 (not prebuilded, exists as source) +if(USE_PREBUILT_LIBS) + add_subdirectory(external/tinyxml2) + set(TinyXML2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2) + set(TinyXML2_LIBRARIES tinyxml2) +else() + cocos_find_package(TinyXML2 TinyXML2 REQUIRED) endif() +message(STATUS "TinyXML2 include dirs: ${TinyXML2_INCLUDE_DIRS}") + +# libjpeg +cocos_find_package(JPEG JPEG REQUIRED) +cocos_find_package(ZLIB ZLIB REQUIRED) + +# minizip (we try to migrate to minizip from https://github.com/nmoinvaz/minizip) +# only msys2 currently provides package for this variant, all other +# dists have packages from zlib, thats very old for us. +# moreover our embedded version modified to quick provide +# functionality needed by cocos. +if(USE_PREBUILT_LIBS OR NOT MINGW) + add_subdirectory(external/unzip) + set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip) + set(MINIZIP_LIBRARIES unzip) + message(STATUS "MINIZIP include dirs: ${MINIZIP_INCLUDE_DIRS}") +else() + cocos_find_package(MINIZIP MINIZIP REQUIRED) + # double check that we have needed functions + include(CheckLibraryExists) + check_library_exists(${MINIZIP_LIBRARIES} "unzGoToFirstFile2" "" MINIZIP_HAS_GOTOFIRSTFILE2) + if(NOT MINIZIP_HAS_GOTOFIRSTFILE2) + message(FATAL_ERROR "Minizip library on you system very old. Please use recent version from https://github.com/nmoinvaz/minizip or enable USE_PREBUILT_LIBS") + endif() + add_definitions(-DMINIZIP_FROM_SYSTEM) +endif() + +cocos_find_package(PNG PNG REQUIRED) +cocos_find_package(TIFF TIFF REQUIRED) +cocos_find_package(WEBSOCKETS WEBSOCKETS REQUIRED) +cocos_find_package(CURL CURL REQUIRED) + +# protobuf-lite (not prebuilded, exists as source) +# TODO: for now we can't use upstream protobuf because these files: +# cocos/editor-support/cocostudio/CSParseBinary.pb.h +# cocos/editor-support/cocostudio/CSParseBinary.pb.cc +# was generated by concrete version of protobuf compiler +# and source file not provided. So these files can be +# compiled only with our in-source version of protobuf-lite +## if(USE_PREBUILT_LIBS) + add_subdirectory(external/protobuf-lite) + set(PROTOBUF_LITE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf-lite/src) + set(PROTOBUF_LITE_LIBRARIES protobuf) +## else() +## cocos_find_package(Protobuf REQUIRED PROTOBUF_LITE_LIBRARIES) +## set(PROTOBUF_LITE_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS}) +## endif() +message(STATUS "Protobuf lite libs: ${PROTOBUF_LITE_LIBRARIES}") +message(STATUS "Protobuf include dirs: ${PROTOBUF_LITE_INCLUDE_DIRS}") + # build for 3rd party libraries if(LINUX OR APPLE) -add_subdirectory(external/Box2D) -add_subdirectory(external/unzip) add_subdirectory(external/xxhash) -add_subdirectory(external/tinyxml2) -add_subdirectory(external/protobuf-lite) endif() # libcocos2d.a diff --git a/README.md b/README.md index 61cb4de288..bdab36e479 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ Contact us [5]: http://www.box2d.org "Box2D" [6]: http://www.chipmunk-physics.net "Chipmunk2D" [7]: http://esotericsoftware.com/ "http://esotericsoftware.com/" -[8]: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Contribution +[8]: https://github.com/cocos2d/cocos2d-x/blob/v3/docs/CONTRIBUTE.md [9]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org" [10]: http://www.twitter.com/cocos2dx "http://www.twitter.com/cocos2dx" [11]: http://t.sina.com.cn/cocos2dx "http://t.sina.com.cn/cocos2dx" diff --git a/build/install-deps-linux.sh b/build/install-deps-linux.sh index 183288af5d..2732ff78f4 100755 --- a/build/install-deps-linux.sh +++ b/build/install-deps-linux.sh @@ -21,6 +21,7 @@ DEPENDS+=' libfontconfig1-dev' DEPENDS+=' libsqlite3-dev' DEPENDS+=' libglew*-dev' DEPENDS+=' libssl-dev' +DEPENDS+=' gnutls-dev' MISSING= echo "Checking for missing packages ..." diff --git a/cmake/Modules/CocosBuildHelpers.cmake b/cmake/Modules/CocosBuildHelpers.cmake index c90ed82c08..07a8e79f1b 100644 --- a/cmake/Modules/CocosBuildHelpers.cmake +++ b/cmake/Modules/CocosBuildHelpers.cmake @@ -36,6 +36,91 @@ function(cocos_mark_resources) endforeach() endfunction() +# cocos_find_package(pkg args...) +# works same as find_package, but do additional care to properly find +# prebuilt libs for cocos +macro(cocos_find_package pkg_name pkg_prefix) + if(NOT USE_PREBUILT_LIBS OR NOT ${pkg_prefix}_FOUND) + find_package(${pkg_name} ${ARGN}) + endif() + if(NOT ${pkg_prefix}_INCLUDE_DIRS AND ${pkg_prefix}_INCLUDE_DIR) + set(${pkg_prefix}_INCLUDE_DIRS ${${pkg_prefix}_INCLUDE_DIR}) + endif() + if(NOT ${pkg_prefix}_LIBRARIES AND ${pkg_prefix}_LIBRARY) + set(${pkg_prefix}_LIBRARIES ${${pkg_prefix}_LIBRARY}) + endif() + + message(STATUS "${pkg_name} include dirs: ${${pkg_prefix}_INCLUDE_DIRS}") +endmacro() + +# cocos_use_pkg(pkg) function. +# This function applies standard package variables (after find_package(pkg) call) to current scope +# Recognized variables: _INCLUDE_DIRS, _LIBRARIES, _LIBRARY_DIRS +# Also if BUILD_SHARED_LIBS variable off, it is try to use _STATIC_* vars before +function(cocos_use_pkg target pkg) + set(prefix ${pkg}) + if(NOT BUILD_SHARED_LIBS) + set(prefix_static ${pkg}_STATIC) + else() + set(prefix_static) + endif() + + set(_include_dirs) + if(prefix_static AND ${prefix_static}_INCLUDE_DIRS) + set(_include_dirs ${${prefix_static}_INCLUDE_DIRS}) + endif() + if(NOT _include_dirs) + set(_include_dirs ${${prefix}_INCLUDE_DIRS}) + endif() + if(NOT _include_dirs) + # backward compat with old package-find scripts + set(_include_dirs ${${prefix}_INCLUDE_DIR}) + endif() + if(_include_dirs) + include_directories(${_include_dirs}) + message(STATUS "${pkg} add to include_dirs: ${_include_dirs}") + endif() + + set(_library_dirs) + if(prefix_static AND ${prefix_static}_LIBRARY_DIRS) + set(_library_dirs ${${prefix_static}_LIBRARY_DIRS}) + endif() + if(NOT _library_dirs) + set(_library_dirs ${${prefix}_LIBRARY_DIRS}) + endif() + if(_library_dirs) + link_directories(${_library_dirs}) + message(STATUS "${pkg} add to link_dirs: ${_library_dirs}") + endif() + + set(_libs) + if(prefix_static AND ${prefix_static}_LIBRARIES) + set(_libs ${${prefix_static}_LIBRARIES}) + endif() + if(NOT _libs) + set(_libs ${${prefix}_LIBRARIES}) + endif() + if(NOT _libs) + set(_libs ${${prefix}_LIBRARY}) + endif() + if(_libs) + target_link_libraries(${target} ${_libs}) + message(STATUS "${pkg} libs added to '${target}': ${_libs}") + endif() + + set(_defs) + if(prefix_static AND ${prefix_static}_CFLAGS_OTHER) + set(_defs ${${prefix_static}_CFLAGS_OTHER}) + endif() + if(NOT _defs) + set(_defs ${${prefix}_DEFINITIONS}) + endif() + if(_defs) + add_definitions(${_defs}) + message(STATUS "${pkg} add definitions: ${_defs}") + endif() +endfunction() + #cmake has some strange defaults, this should help us a lot #Please use them everywhere diff --git a/cmake/Modules/CocosUsePrebuiltLibs.cmake b/cmake/Modules/CocosUsePrebuiltLibs.cmake new file mode 100644 index 0000000000..15344102f3 --- /dev/null +++ b/cmake/Modules/CocosUsePrebuiltLibs.cmake @@ -0,0 +1,169 @@ +# CocosUsePrebuiltLibs - sets external libs variables to link with + +# START CONFIG + +set(_chipmunk_inc chipmunk.h) +set(_chipmunk_inc_paths chipmunk) +set(_chipmunk_libs chipmunk libchipmunk) + +set(_curl_inc curl/curl.h) +set(_curl_libs crypto ssl libeay32 ssleay32 curl libcurl_imp libcurl) + +set(_freetype2_prefix FREETYPE) +set(_freetype2_inc ft2build.h freetype/freetype.h) +set(_freetype2_inc_paths freetype2) +set(_freetype2_libs freetype freetype250) + +set(_jpeg_inc jpeglib.h) +set(_jpeg_libs jpeg libjpeg) + +set(_png_inc png.h) +set(_png_libs png libpng) + +set(_tiff_inc tiff.h) +set(_tiff_libs tiff libtiff) + +set(_webp_inc decode.h) +set(_webp_libs webp libwebp) + +set(_websockets_inc libwebsockets.h) +set(_websockets_libs websockets libwebsockets) + +set(_glfw3_inc glfw3.h) +set(_glfw3_libs glfw3 libglfw3) + +set(_sqlite3_inc sqlite3.h) +set(_sqlite3_libs sqlite3) + +set(_gles_prefix GLEW) +set(_gles_inc glew.h) +set(_gles_inc_paths OGLES) +set(_gles_libs glew32) + +set(_icon_prefix ICONV) +set(_icon_inc iconv.h) +set(_icon_libs libiconv) + +set(_MP3Decoder_prefix MPG123) +set(_MP3Decoder_inc mpg123.h) +set(_MP3Decoder_libs libmpg123) + +set(_OggDecoder_prefix VORBIS) +set(_OggDecoder_inc ogg/ogg.h) +set(_OggDecoder_libs libogg libvorbis libvorbisfile) + +set(_OpenalSoft_prefix OPENAL) +set(_OpenalSoft_inc al.h) +set(_OpenalSoft_inc_paths AL) +set(_OpenalSoft_libs OpenAL32) + +set(_zlib_inc zlib.h) +set(_zlib_libs libzlib) + +set(_fmod_prefix FMODEX) +set(_fmod_inc fmod.h) +set(_fmod_libs fmodex fmodex64 fmodexL fmodexL64) + +set(all_prebuilt_libs + chipmunk + curl + freetype2 + jpeg + png + tiff + webp + websockets +) + + +if(MACOSX) + list(APPEND all_prebuilt_libs glfw3) +endif() + +# We use MSVC instead of WINDOWS because it can be mingw that can't use our prebuilt libs +if(MSVC) + list(APPEND all_prebuilt_libs glfw3 sqlite3 gles icon MP3Decoder OggDecoder OpenalSoft zlib) +endif() + +if(LINUX) + list(APPEND all_prebuilt_libs fmod) +endif() + +# END CONFIG + +foreach(_lib ${all_prebuilt_libs}) + if(_${_lib}_prefix) + set(_prefix ${_${_lib}_prefix}) + else() + # auto-prefix is uppercased name + string(TOUPPER ${_lib} _prefix) + endif() + + set(roots + ${COCOS_EXTERNAL_DIR}/${_lib} + ${COCOS_EXTERNAL_DIR}/${PLATFORM_FOLDER}-specific/${_lib} + ) + foreach(_root ${roots}) + if(EXISTS ${_root}) + set(include_dir_candidates + ${_root}/include + ${_root}/include/${ARCH_DIR} + ${_root}/include/${PLATFORM_FOLDER} + ${_root}/include/${PLATFORM_FOLDER}/${ARCH_DIR} + ) + set(include_dirs) + foreach(_dir ${include_dir_candidates}) + if(EXISTS ${_dir}) + # find all include paths + if(_${_lib}_inc_paths) + set(_suffixes ${_${_lib}_inc_paths}) + else() + set(_suffixes include) + endif() + foreach(_inc_name ${_${_lib}_inc}) + unset(_inc_tmp CACHE) + find_path(_inc_tmp ${_inc_name} PATH_SUFFIXES ${_suffixes} PATHS ${_dir} NO_DEFAULT_PATH) + if(_inc_tmp) + list(APPEND include_dirs ${_inc_tmp}) + endif() + endforeach() + endif(EXISTS ${_dir}) + endforeach() + if(include_dirs) + set(${_prefix}_INCLUDE_DIRS ${include_dirs} CACHE PATH "Path to includes for ${_prefix}" FORCE) + endif() + #message(STATUS "${_lib} ${_prefix}_INCLUDE_DIRS: ${${_prefix}_INCLUDE_DIRS}") + + set(lib_dir_candidates + ${_root}/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${_root}/prebuilt/${PLATFORM_FOLDER} + ${_root}/prebuilt/${PLATFORM_FOLDER}/release-lib + ${_root}/prebuilt/${ARCH_DIR} + ${_root}/libraries/${PLATFORM_FOLDER} + ${_root}/prebuilt + ) + set(libs) + foreach(_dir ${lib_dir_candidates}) + if(EXISTS ${_dir}) + # find all libs + foreach(_lib_name ${_${_lib}_libs}) + unset(_lib_tmp CACHE) + find_library(_lib_tmp ${_lib_name} PATHS ${_dir} NO_DEFAULT_PATH) + if(_lib_tmp) + list(APPEND libs ${_lib_tmp}) + endif() + endforeach() + endif(EXISTS ${_dir}) + endforeach() + if(libs) + set(${_prefix}_LIBRARIES ${libs} CACHE STRING "Libraries to link for ${_prefix}" FORCE) + endif() + #message(STATUS "${_lib} ${_prefix}_LIBRARIES: ${${_prefix}_LIBRARIES}") + + if(${_prefix}_LIBRARIES AND ${_prefix}_INCLUDE_DIRS) + set(${_prefix}_FOUND YES) + endif() + + endif(EXISTS ${_root}) + endforeach() +endforeach() diff --git a/cmake/Modules/FindCURL.cmake b/cmake/Modules/FindCURL.cmake new file mode 100644 index 0000000000..e286d78712 --- /dev/null +++ b/cmake/Modules/FindCURL.cmake @@ -0,0 +1,86 @@ +#.rst: +# FindCURL +# -------- +# +# Find curl +# +# Find the native CURL headers and libraries. +# +# :: +# +# CURL_INCLUDE_DIRS - where to find curl/curl.h, etc. +# CURL_LIBRARIES - List of libraries when using curl. +# CURL_FOUND - True if curl found. +# CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8) + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# Copyright 2012 Rolf Eike Beer +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(CURL_LIBRARY_NAMES + curl +# Windows MSVC prebuilts: + curllib + libcurl_imp + curllib_static +# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): + libcurl + ) + +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + pkg_search_module(CURL QUIET libcurl) +endif() + +if(NOT CURL_FOUND) + + # Look for the header file. + find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) + mark_as_advanced(CURL_INCLUDE_DIR) + + # Look for the library (sorted from most current/relevant entry to least). + find_library(CURL_LIBRARY NAMES + curl + # Windows MSVC prebuilts: + curllib + libcurl_imp + curllib_static + # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): + libcurl + ) + mark_as_advanced(CURL_LIBRARY) + + if(CURL_INCLUDE_DIR) + foreach(_curl_version_header curlver.h curl.h) + if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") + file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") + + string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}") + unset(curl_version_str) + break() + endif() + endforeach() + endif() + + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL + REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR + VERSION_VAR CURL_VERSION_STRING) + + if(CURL_FOUND) + set(CURL_LIBRARIES ${CURL_LIBRARY}) + set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) + endif() + +endif() + diff --git a/cmake/Modules/FindFMODEX.cmake b/cmake/Modules/FindFMODEX.cmake new file mode 100644 index 0000000000..54e4d4a800 --- /dev/null +++ b/cmake/Modules/FindFMODEX.cmake @@ -0,0 +1,51 @@ +#.rst: +# FindFMODEX +# ------------ +# +# Locate FMOD Ex library +# +# This module defines +# +# :: +# +# FMODEX_LIBRARIES, the library to link against +# FMODEX_FOUND, if false, do not try to link to fmodex +# FMODEX_INCLUDE_DIRS, where to find headers. +# + +find_path(FMODEX_INCLUDE_DIR fmod.h + HINTS ENV FMODEX_DIR + PATH_SUFFIXES include/fmodex include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +find_library(FMODEX_LIBRARY NAMES fmodex fmodex64 + HINTS ENV FMODEX_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +set(FMODEX_INCLUDE_DIRS "${FMODEX_INCLUDE_DIR}") +set(FMODEX_LIBRARIES "${FMODEX_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(FMODEX DEFAULT_MSG FMODEX_LIBRARIES FMODEX_INCLUDE_DIRS) + +mark_as_advanced(FMODEX_INCLUDE_DIR FMODEX_LIBRARY FMODEX_INCLUDE_DIRS FMODEX_LIBRARIES) + diff --git a/cmake/Modules/FindFontconfig.cmake b/cmake/Modules/FindFontconfig.cmake new file mode 100644 index 0000000000..d5da113c49 --- /dev/null +++ b/cmake/Modules/FindFontconfig.cmake @@ -0,0 +1,17 @@ +# FindFontconfig +# -------------- +# +# Locate Fontconfig library +# + +if(NOT FONTCONFIG_FOUND) + find_package(PkgConfig) + pkg_search_module(FONTCONFIG fontconfig) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Fontconfig + REQUIRED_VARS FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIRS + VERSION_VAR FONTCONFIG_VERSION + ) + diff --git a/cmake/Modules/FindFreetype.cmake b/cmake/Modules/FindFreetype.cmake new file mode 100644 index 0000000000..7935a93790 --- /dev/null +++ b/cmake/Modules/FindFreetype.cmake @@ -0,0 +1,168 @@ +#.rst: +# FindFreetype +# ------------ +# +# Locate FreeType library +# +# This module defines +# +# :: +# +# FREETYPE_LIBRARIES, the library to link against +# FREETYPE_FOUND, if false, do not try to link to FREETYPE +# FREETYPE_INCLUDE_DIRS, where to find headers. +# FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8) +# This is the concatenation of the paths: +# FREETYPE_INCLUDE_DIR_ft2build +# FREETYPE_INCLUDE_DIR_freetype2 +# +# +# +# $FREETYPE_DIR is an environment variable that would correspond to the +# ./configure --prefix=$FREETYPE_DIR used in building FREETYPE. + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Created by Eric Wing. +# Modifications by Alexander Neundorf. +# This file has been renamed to "FindFreetype.cmake" instead of the correct +# "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex. + +# Try find freetype for our arch in external folder +#todo: fix location of freetype includes for linux android on cocos prebuilt repo +#i.e we should not need to include an extra dir of /freetype2 + +# Try pkg-config first (because it provided deps info) +if(NOT FREETYPE_FOUND) + find_package(PkgConfig) + pkg_search_module(FREETYPE freetype2) +endif() +if(NOT FREETYPE_FOUND) + +# Ugh, FreeType seems to use some #include trickery which +# makes this harder than it should be. It looks like they +# put ft2build.h in a common/easier-to-find location which +# then contains a #include to a more specific header in a +# more specific location (#include ). +# Then from there, they need to set a bunch of #define's +# so you can do something like: +# #include FT_FREETYPE_H +# Unfortunately, using CMake's mechanisms like include_directories() +# wants explicit full paths and this trickery doesn't work too well. +# I'm going to attempt to cut out the middleman and hope +# everything still works. +find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h + HINTS + ENV FREETYPE_DIR + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + ENV GTKMM_BASEPATH + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES include/freetype2 include +) + +find_path(FREETYPE_INCLUDE_DIR_freetype2 + NAMES + freetype/config/ftheader.h + config/ftheader.h + HINTS + ENV FREETYPE_DIR + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + ENV GTKMM_BASEPATH + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES include/freetype2 include +) + +find_library(FREETYPE_LIBRARY + NAMES freetype libfreetype freetype219 + HINTS + ENV FREETYPE_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + ENV GTKMM_BASEPATH + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] +) + +# set the user variables +if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) + set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}") + list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIRS) +endif() +set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") + +if(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") +elseif(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") +endif() + +if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H) + file(STRINGS "${FREETYPE_H}" freetype_version_str + REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$") + + unset(FREETYPE_VERSION_STRING) + foreach(VPART MAJOR MINOR PATCH) + foreach(VLINE ${freetype_version_str}) + if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}") + string(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1" + FREETYPE_VERSION_PART "${VLINE}") + if(FREETYPE_VERSION_STRING) + set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}") + else() + set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}") + endif() + unset(FREETYPE_VERSION_PART) + endif() + endforeach() + endforeach() +endif() + +set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype + REQUIRED_VARS FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIRS + VERSION_VAR FREETYPE_VERSION_STRING) + +endif(NOT FREETYPE_FOUND) + +mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build) diff --git a/cmake/Modules/FindGLFW3.cmake b/cmake/Modules/FindGLFW3.cmake index 07799b25cc..5080a71857 100644 --- a/cmake/Modules/FindGLFW3.cmake +++ b/cmake/Modules/FindGLFW3.cmake @@ -27,6 +27,25 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Try find glfw for our arch in external folder +if(USE_PREBUILT_LIBS) + find_path(GLFW3_INCLUDE_DIR glfw3.h + PATHS ${COCOS_EXTERNAL_DIR}/glfw3/include/${PLATFORM_FOLDER} + NO_DEFAULT_PATH + ) + find_library(GLFW3_LIBRARY NAMES glfw3 libglfw3 lgfw + PATHS + ${COCOS_EXTERNAL_DIR}/glfw3/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${COCOS_EXTERNAL_DIR}/glfw3/prebuilt/${PLATFORM_FOLDER} + NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT GLFW3_INCLUDE_DIR OR NOT GLFW3_LIBRARY) + unset(GLFW3_INCLUDE_DIR CACHE) + unset(GLFW3_LIBRARY CACHE) + endif() +endif(USE_PREBUILT_LIBS) + FIND_PATH(GLFW3_INCLUDE_DIR glfw3.h HINTS ENV GLFW3_DIR diff --git a/cmake/Modules/FindJPEG.cmake b/cmake/Modules/FindJPEG.cmake new file mode 100644 index 0000000000..1fbb90328e --- /dev/null +++ b/cmake/Modules/FindJPEG.cmake @@ -0,0 +1,69 @@ +#.rst: +# FindJPEG +# -------- +# +# Find JPEG +# +# Find the native JPEG includes and library This module defines +# +# :: +# +# JPEG_INCLUDE_DIRS, where to find jpeglib.h, etc. +# JPEG_LIBRARIES, the libraries needed to use JPEG. +# JPEG_FOUND, If false, do not try to use JPEG. +# +# also defined, but not for general use are +# +# :: +# +# JPEG_LIBRARY, where to find the JPEG library. + +#============================================================================= +# Copyright 2001-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(USE_PREBUILT_LIBS) + find_path(JPEG_INCLUDE_DIR jpeglib.h + PATH_SUFFIXES include/${PLATFORM_FOLDER} include + PATHS ${COCOS_EXTERNAL_DIR}/jpeg + NO_DEFAULT_PATH + ) + find_library(JPEG_LIBRARY NAMES jpeg + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${COCOS_EXTERNAL_DIR}/jpeg + NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT JPEG_INCLUDE_DIR OR NOT JPEG_LIBRARY) + unset(JPEG_INCLUDE_DIR CACHE) + unset(JPEG_LIBRARY CACHE) + endif() +endif() + +find_path(JPEG_INCLUDE_DIR jpeglib.h) + +set(JPEG_NAMES ${JPEG_NAMES} jpeg) +find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} ) + +# handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR) + +if(JPEG_FOUND) + set(JPEG_INCLUDE_DIRS ${JPEG_INCLUDE_DIR}) + set(JPEG_LIBRARIES ${JPEG_LIBRARY}) +endif() + +mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIRS ) diff --git a/cmake/Modules/FindMINIZIP.cmake b/cmake/Modules/FindMINIZIP.cmake new file mode 100644 index 0000000000..93efa3595d --- /dev/null +++ b/cmake/Modules/FindMINIZIP.cmake @@ -0,0 +1,60 @@ +#.rst: +# FindMINIZIP +# ------------ +# +# Locate minizip library (from zlib package) +# +# This module defines +# +# :: +# +# MINIZIP_LIBRARIES, the library to link against +# MINIZIP_FOUND, if false, do not try to link to fmodex +# MINIZIP_INCLUDE_DIRS, where to find headers. +# + +# Try pkg-config first +if(NOT MINIZIP_LIBRARY AND NOT MINIZIP_INCLUDE_DIR) + find_package(PkgConfig) + pkg_search_module(MINIZIP minizip) + if(MINIZIP_FOUND) + return() + endif() +endif() + +find_path(MINIZIP_INCLUDE_DIR minizip/unzip.h + HINTS ENV MINIZIP_DIR + PATH_SUFFIXES include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +find_library(MINIZIP_LIBRARY NAMES minizip libminizip + HINTS ENV MINIZIP_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +set(MINIZIP_INCLUDE_DIRS "${MINIZIP_INCLUDE_DIR}") +set(MINIZIP_LIBRARIES "${MINIZIP_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(MINIZIP DEFAULT_MSG MINIZIP_LIBRARIES MINIZIP_INCLUDE_DIRS) + +mark_as_advanced(MINIZIP_INCLUDE_DIR MINIZIP_LIBRARY) + diff --git a/cmake/Modules/FindMPG123.cmake b/cmake/Modules/FindMPG123.cmake new file mode 100644 index 0000000000..61e450a2c2 --- /dev/null +++ b/cmake/Modules/FindMPG123.cmake @@ -0,0 +1,17 @@ +# - Find mpg123 +# Find the native mpg123 includes and libraries +# +# MPG123_INCLUDE_DIRS - where to find mpg123.h, etc. +# MPG123_LIBRARIES - List of libraries when using mpg123. +# MPG123_FOUND - True if mpg123 found. + +find_path(MPG123_INCLUDE_DIR mpg123.h) +find_library(MPG123_LIBRARY NAMES mpg123 libmpg123) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MPG123 DEFAULT_MSG MPG123_INCLUDE_DIR MPG123_LIBRARY) + +set(MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIR}) +set(MPG123_LIBRARIES ${MPG123_LIBRARY}) + +mark_as_advanced(MPG123_INCLUDE_DIR MPG123_LIBRARY) diff --git a/cmake/Modules/FindOgg.cmake b/cmake/Modules/FindOgg.cmake new file mode 100644 index 0000000000..a3c06d2546 --- /dev/null +++ b/cmake/Modules/FindOgg.cmake @@ -0,0 +1,20 @@ +# - Find ogg +# Find the native ogg includes and libraries +# +# OGG_INCLUDE_DIRS - where to find ogg.h, etc. +# OGG_LIBRARIES - List of libraries when using ogg. +# OGG_FOUND - True if ogg found. + +find_path(OGG_INCLUDE_DIR ogg/ogg.h) +# MSVC built ogg may be named ogg_static. +# The provided project files name the library with the lib prefix. +find_library(OGG_LIBRARY NAMES ogg ogg_static libogg libogg_static) +# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OGG DEFAULT_MSG OGG_INCLUDE_DIR OGG_LIBRARY) + +set(OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR}) +set(OGG_LIBRARIES ${OGG_LIBRARY}) + +mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY) diff --git a/cmake/Modules/FindPNG.cmake b/cmake/Modules/FindPNG.cmake new file mode 100644 index 0000000000..53cd8385da --- /dev/null +++ b/cmake/Modules/FindPNG.cmake @@ -0,0 +1,178 @@ +#.rst: +# FindPNG +# ------- +# +# Find the native PNG includes and library +# +# +# +# This module searches libpng, the library for working with PNG images. +# +# It defines the following variables +# +# :: +# +# PNG_INCLUDE_DIRS, where to find png.h, etc. +# PNG_LIBRARIES, the libraries to link against to use PNG. +# PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files. +# PNG_FOUND, If false, do not try to use PNG. +# PNG_VERSION_STRING - the version of the PNG library found (since CMake 2.8.8) +# +# Also defined, but not for general use are +# +# :: +# +# PNG_LIBRARY, where to find the PNG library. +# +# For backward compatiblity the variable PNG_INCLUDE_DIR is also set. +# It has the same value as PNG_INCLUDE_DIRS. +# +# Since PNG depends on the ZLib compression library, none of the above +# will be defined unless ZLib can be found. + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(PNG_FIND_QUIETLY) + set(_FIND_ZLIB_ARG QUIET) +endif() +find_package(ZLIB ${_FIND_ZLIB_ARG}) + +if(USE_PREBUILT_LIBS) + find_path(PNG_PNG_INCLUDE_DIR png.h + PATH_SUFFIXES include/${PLATFORM_FOLDER} include + PATHS ${COCOS_EXTERNAL_DIR}/png NO_DEFAULT_PATH + ) + find_library(PNG_LIBRARY NAMES png libpng + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${COCOS_EXTERNAL_DIR}/png NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT PNG_PNG_INCLUDE_DIR OR NOT PNG_LIBRARY) + unset(PNG_PNG_INCLUDE_DIR CACHE) + unset(PNG_LIBRARY CACHE) + endif() +endif() + +if(ZLIB_FOUND) + find_path(PNG_PNG_INCLUDE_DIR png.h + HINTS ENV PNG_DIR + PATH_SUFFIXES include/libpng include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + + list(APPEND PNG_NAMES png libpng) + unset(PNG_NAMES_DEBUG) + set(_PNG_VERSION_SUFFIXES 17 16 15 14 12) + if (PNG_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\..*)?$") + string(REGEX REPLACE + "^([0-9]+)\\.([0-9]+).*" "\\1\\2" + _PNG_VERSION_SUFFIX_MIN "${PNG_FIND_VERSION}") + if (PNG_FIND_VERSION_EXACT) + set(_PNG_VERSION_SUFFIXES ${_PNG_VERSION_SUFFIX_MIN}) + else () + string(REGEX REPLACE + "${_PNG_VERSION_SUFFIX_MIN}.*" "${_PNG_VERSION_SUFFIX_MIN}" + _PNG_VERSION_SUFFIXES "${_PNG_VERSION_SUFFIXES}") + endif () + unset(_PNG_VERSION_SUFFIX_MIN) + endif () + foreach(v IN LISTS _PNG_VERSION_SUFFIXES) + list(APPEND PNG_NAMES png${v} libpng${v}) + list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d) + endforeach() + unset(_PNG_VERSION_SUFFIXES) + # For compatiblity with versions prior to this multi-config search, honor + # any PNG_LIBRARY that is already specified and skip the search. + if(NOT PNG_LIBRARY) + find_library(PNG_LIBRARY_RELEASE + NAMES ${PNG_NAMES} + HINTS ENV PNG_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt + ) + find_library(PNG_LIBRARY_DEBUG + NAMES ${PNG_NAMES_DEBUG} + HINTS ENV PNG_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt + ) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(PNG) + mark_as_advanced(PNG_LIBRARY_RELEASE PNG_LIBRARY_DEBUG) + endif() + unset(PNG_NAMES) + unset(PNG_NAMES_DEBUG) + + # Set by select_library_configurations(), but we want the one from + # find_package_handle_standard_args() below. + unset(PNG_FOUND) + + if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) + # png.h includes zlib.h. Sigh. + set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) + set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity + set(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY}) + + if (CYGWIN) + if(BUILD_SHARED_LIBS) + # No need to define PNG_USE_DLL here, because it's default for Cygwin. + else() + set (PNG_DEFINITIONS -DPNG_STATIC) + endif() + endif () + + endif () + + if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h") + file(STRINGS "${PNG_PNG_INCLUDE_DIR}/png.h" png_version_str REGEX "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\".+\"") + + string(REGEX REPLACE "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\"([^\"]+)\".*" "\\1" PNG_VERSION_STRING "${png_version_str}") + unset(png_version_str) + endif () +endif() + +# handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(PNG + REQUIRED_VARS PNG_LIBRARY PNG_PNG_INCLUDE_DIR + VERSION_VAR PNG_VERSION_STRING) + +mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY ) diff --git a/cmake/Modules/FindTIFF.cmake b/cmake/Modules/FindTIFF.cmake new file mode 100644 index 0000000000..d9b5954c2e --- /dev/null +++ b/cmake/Modules/FindTIFF.cmake @@ -0,0 +1,106 @@ +#.rst: +# FindTIFF +# -------- +# +# Find TIFF library +# +# Find the native TIFF includes and library This module defines +# +# :: +# +# TIFF_INCLUDE_DIR, where to find tiff.h, etc. +# TIFF_LIBRARIES, libraries to link against to use TIFF. +# TIFF_FOUND, If false, do not try to use TIFF. +# +# also defined, but not for general use are +# +# :: +# +# TIFF_LIBRARY, where to find the TIFF library. + +#============================================================================= +# Copyright 2002-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3) + +if(USE_PREBUILT_LIBS) + find_path(TIFF_INCLUDE_DIR tiff.h + PATH_SUFFIXES include/${PLATFORM_FOLDER} include + PATHS ${COCOS_EXTERNAL_DIR}/tiff NO_DEFAULT_PATH + ) + find_library(TIFF_LIBRARY NAMES ${TIFF_NAMES} + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${COCOS_EXTERNAL_DIR}/tiff NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT TIFF_INCLUDE_DIR OR NOT TIFF_LIBRARY) + unset(TIFF_INCLUDE_DIR CACHE) + unset(TIFF_LIBRARY CACHE) + endif() +endif() + +find_path(TIFF_INCLUDE_DIR tiff.h + HINTS ENV TIFF_DIR + PATH_SUFFIXES include/libtiff include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +find_library(TIFF_LIBRARY + NAMES ${TIFF_NAMES} + HINTS ENV TIFF_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt + ) + +if(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h") + file(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str + REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*") + + string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" + "\\1" TIFF_VERSION_STRING "${tiff_version_str}") + unset(tiff_version_str) +endif() + +set(TIFF_INCLUDE_DIRS ${TIFF_INCLUDE_DIR}) + +# handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF + REQUIRED_VARS TIFF_LIBRARY TIFF_INCLUDE_DIRS + VERSION_VAR TIFF_VERSION_STRING + ) + +if(TIFF_FOUND) + set( TIFF_LIBRARIES ${TIFF_LIBRARY} ) +endif() + +mark_as_advanced(TIFF_INCLUDE_DIRS TIFF_LIBRARY) diff --git a/cmake/Modules/FindTinyXML2.cmake b/cmake/Modules/FindTinyXML2.cmake new file mode 100644 index 0000000000..7f155bfbea --- /dev/null +++ b/cmake/Modules/FindTinyXML2.cmake @@ -0,0 +1,74 @@ +#.rst: +# FindTinyXML2 +# ------------ +# +# Locate tinyxml2 library +# +# This module defines +# +# :: +# +# TINYXML2_LIBRARIES, the library to link against +# TINYXML2_FOUND, if false, do not try to link to tinyxml2 +# TINYXML2_INCLUDE_DIRS, where to find headers. +# + +# Try find tinyxml for our arch in external folder +if(USE_PREBUILT_LIBS) + find_path(TinyXML2_INCLUDE_DIR tinyxml2.h + PATH_SUFFIXES + include/tinyxml2 + include + PATHS ${COCOS_EXTERNAL_DIR}/tinyxml2 + NO_DEFAULT_PATH + ) + find_library(TinyXML2_LIBRARY NAMES tinyxml2 libtinyxml2 + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${COCOS_EXTERNAL_DIR}/tinyxml2 + NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT TinyXML2_INCLUDE_DIR OR NOT TinyXML2_LIBRARY) + unset(TinyXML2_INCLUDE_DIR CACHE) + unset(TinyXML2_LIBRARY CACHE) + endif() +endif(USE_PREBUILT_LIBS) + +find_path(TinyXML2_INCLUDE_DIR tinyxml2.h + HINTS ENV TinyXML2_DIR + PATH_SUFFIXES include/tinyxml2 include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +find_library(TinyXML2_LIBRARY + NAMES tinyxml2 libtinyxml2 + HINTS ENV TinyXML2_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +set(TinyXML2_INCLUDE_DIRS "${TinyXML2_INCLUDE_DIR}") +set(TinyXML2_LIBRARIES "${TinyXML2_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TinyXML2_LIBRARIES TinyXML2_INCLUDE_DIRS) + +mark_as_advanced(TinyXML2_INCLUDE_DIRS TinyXML2_LIBRARIES TinyXML2_LIBRARY) diff --git a/cmake/Modules/FindVorbis.cmake b/cmake/Modules/FindVorbis.cmake new file mode 100644 index 0000000000..163dda6fa6 --- /dev/null +++ b/cmake/Modules/FindVorbis.cmake @@ -0,0 +1,29 @@ +# - Find vorbis +# Find the native vorbis includes and libraries +# +# VORBIS_INCLUDE_DIRS - where to find vorbis.h, etc. +# VORBIS_LIBRARIES - List of libraries when using vorbis(file). +# VORBIS_FOUND - True if vorbis found. + +find_package(Ogg) +if(OGG_FOUND) + find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) + # MSVC built vorbis may be named vorbis_static + # The provided project files name the library with the lib prefix. + find_library(VORBIS_LIBRARY NAMES vorbis vorbis_static libvorbis libvorbis_static) + find_library(VORBISFILE_LIBRARY NAMES vorbisfile vorbisfile_static libvorbisfile libvorbisfile_static) + # Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND + # to TRUE if all listed variables are TRUE. + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(VORBIS DEFAULT_MSG VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY) +endif(OGG_FOUND) + +if(VORBIS_FOUND) + set(VORBIS_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR}) + set(VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) +else(VORBIS_FOUND) + set(VORBIS_INCLUDE_DIRS) + set(VORBIS_LIBRARIES) +endif(VORBIS_FOUND) + +mark_as_advanced(VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY) diff --git a/cmake/Modules/FindWEBSOCKETS.cmake b/cmake/Modules/FindWEBSOCKETS.cmake new file mode 100644 index 0000000000..aab748a5e0 --- /dev/null +++ b/cmake/Modules/FindWEBSOCKETS.cmake @@ -0,0 +1,68 @@ +#.rst: +# FindWEBSOCKETS +# -------- +# +# Find websockets library +# +# :: +# +# WEBSOCKETS_INCLUDE_DIRS, where to find libwebsockets.h. +# WEBSOCKETS_LIBRARIES, the libraries needed to use WEBSOCKETS. +# WEBSOCKETS_FOUND, If false, do not try to use WEBSOCKETS. +# + +if(USE_PREBUILT_LIBS) + find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h + PATH_SUFFIXES include/${PLATFORM_FOLDER} include + PATHS ${COCOS_EXTERNAL_DIR}/websockets + NO_DEFAULT_PATH + ) + find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${COCOS_EXTERNAL_DIR}/websockets + NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT WEBSOCKETS_INCLUDE_DIR OR NOT WEBSOCKETS_LIBRARY) + unset(WEBSOCKETS_INCLUDE_DIR CACHE) + unset(WEBSOCKETS_LIBRARY CACHE) + endif() +endif() + +find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h + HINTS ENV WEBSOCKETS_DIR + PATH_SUFFIXES include/websockets include/libwebsockets include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ) + +find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets + HINTS ENV WEBSOCKETS_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt + ) + +set(WEBSOCKETS_INCLUDE_DIRS ${WEBSOCKETS_INCLUDE_DIR}) +set(WEBSOCKETS_LIBRARIES ${WEBSOCKETS_LIBRARY}) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(WEBSOCKETS DEFAULT_MSG WEBSOCKETS_LIBRARIES WEBSOCKETS_INCLUDE_DIRS) + +mark_as_advanced(WEBSOCKETS_LIBRARIES WEBSOCKETS_INCLUDE_DIRS) diff --git a/cmake/Modules/FindWebP.cmake b/cmake/Modules/FindWebP.cmake index 4b716f55b8..5c1d378d0b 100644 --- a/cmake/Modules/FindWebP.cmake +++ b/cmake/Modules/FindWebP.cmake @@ -27,6 +27,27 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Try find WebP for our arch in external folder +if(USE_PREBUILT_LIBS) + find_path(WEBP_INCLUDE_DIR decode.h + PATH_SUFFIXES include/${PLATFORM_FOLDER} include + PATHS ${COCOS_EXTERNAL_DIR}/webp + NO_DEFAULT_PATH + ) + find_library(WEBP_LIBRARY NAMES webp libwebp + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${COCOS_EXTERNAL_DIR}/webp + NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT WEBP_INCLUDE_DIR OR NOT WEBP_LIBRARY) + unset(WEBP_INCLUDE_DIR CACHE) + unset(WEBP_LIBRARY CACHE) + endif() +endif(USE_PREBUILT_LIBS) + FIND_PATH(WEBP_INCLUDE_DIR decode.h HINTS ENV WEBP_DIR @@ -43,7 +64,7 @@ FIND_PATH(WEBP_INCLUDE_DIR decode.h ) FIND_LIBRARY(WEBP_LIBRARY - NAMES WEBP libWEBP + NAMES webp libwebp HINTS ENV WEBP_DIR PATH_SUFFIXES lib diff --git a/cmake/Modules/SelectLibraryConfigurations.cmake b/cmake/Modules/SelectLibraryConfigurations.cmake new file mode 100644 index 0000000000..d7108562b1 --- /dev/null +++ b/cmake/Modules/SelectLibraryConfigurations.cmake @@ -0,0 +1,81 @@ +#.rst: +# SelectLibraryConfigurations +# --------------------------- +# +# +# +# select_library_configurations( basename ) +# +# This macro takes a library base name as an argument, and will choose +# good values for basename_LIBRARY, basename_LIBRARIES, +# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what +# has been found and set. If only basename_LIBRARY_RELEASE is defined, +# basename_LIBRARY will be set to the release value, and +# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND. +# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will +# take the debug value, and basename_LIBRARY_RELEASE will be set to +# basename_LIBRARY_RELEASE-NOTFOUND. +# +# If the generator supports configuration types, then basename_LIBRARY +# and basename_LIBRARIES will be set with debug and optimized flags +# specifying the library to be used for the given configuration. If no +# build type has been set or the generator in use does not support +# configuration types, then basename_LIBRARY and basename_LIBRARIES will +# take only the release value, or the debug value if the release one is +# not set. + +#============================================================================= +# Copyright 2009 Will Dicharry +# Copyright 2005-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This macro was adapted from the FindQt4 CMake module and is maintained by Will +# Dicharry . + +macro( select_library_configurations basename ) + if(NOT ${basename}_LIBRARY_RELEASE) + set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.") + endif() + if(NOT ${basename}_LIBRARY_DEBUG) + set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.") + endif() + + if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND + NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND + ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) ) + # if the generator supports configuration types or CMAKE_BUILD_TYPE + # is set, then set optimized and debug options. + set( ${basename}_LIBRARY "" ) + foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) + list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) + endforeach() + foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) + list( APPEND ${basename}_LIBRARY debug "${_libname}" ) + endforeach() + elseif( ${basename}_LIBRARY_RELEASE ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + elseif( ${basename}_LIBRARY_DEBUG ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} ) + else() + set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND") + endif() + + set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) + + if( ${basename}_LIBRARY ) + set( ${basename}_FOUND TRUE ) + endif() + + mark_as_advanced( ${basename}_LIBRARY_RELEASE + ${basename}_LIBRARY_DEBUG + ) +endmacro() diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 17aea6026d..4cb2180915 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -231,7 +231,7 @@ void ClippingNode::drawFullScreenQuadClearStencil() void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { - if(!_visible) + if (!_visible || !hasContent()) return; uint32_t flags = processParentFlags(parentTransform, parentFlags); @@ -327,6 +327,11 @@ void ClippingNode::setStencil(Node *stencil) _stencil = stencil; } +bool ClippingNode::hasContent() const +{ + return _children.size() > 0; +} + GLfloat ClippingNode::getAlphaThreshold() const { return _alphaThreshold; diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index ba9301e590..9700681638 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -58,7 +58,14 @@ public: */ Node* getStencil() const; void setStencil(Node *stencil); - + + /** If stencil has no childre it will not be drawn. + If you have custom stencil-based node with stencil drawing mechanics other then children-based, + then this method should return true every time you wish stencil to be visited. + By default returns true if has any children attached. + */ + virtual bool hasContent() const; + /** The alpha threshold. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. Should be a float between 0 and 1. diff --git a/cocos/3d/CMakeLists.txt b/cocos/3d/CMakeLists.txt index ce58d57fbb..0e35a5a63e 100644 --- a/cocos/3d/CMakeLists.txt +++ b/cocos/3d/CMakeLists.txt @@ -1,5 +1,5 @@ -if(WINDOWS AND NOT BUILD_STATIC) +if(WINDOWS AND BUILD_SHARED_LIBS) ADD_DEFINITIONS (-D_USE3DDLL) endif() diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index fb6830007c..4eda8daac8 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -31,10 +31,6 @@ if(WINDOWS) ADD_DEFINITIONS(-DUNICODE -D_UNICODE) endif() -if(WINDOWS AND NOT BUILD_STATIC) - ADD_DEFINITIONS (-D_USRDLL) -endif() - include(2d/CMakeLists.txt) include(3d/CMakeLists.txt) include(platform/CMakeLists.txt) @@ -46,6 +42,7 @@ include(deprecated/CMakeLists.txt) include(ui/CMakeLists.txt) include(network/CMakeLists.txt) include(audio/CMakeLists.txt) +include_directories(audio/include) include(storage/CMakeLists.txt) if(BUILD_EDITOR_COCOSBUILDER) @@ -81,77 +78,27 @@ set(COCOS_SRC cocos2d.cpp ${COCOS_EXTENSIONS_SRC} ) -if(MACOSX OR APPLE) - include(FindFreetype REQUIRED) - - if(NOT FREETYPE_FOUND) - if(IOS) - FIND_LIBRARY(FREETYPE_LIBRARIES NAMES libfreetype PATHS "../external/freetype2/prebuilt/ios" DOC "Freetype includes") - find_path(FREETYPE_INCLUDE_DIRS ft2build.h "../external/freetype2/include/ios" "../external/freetype2/include/ios/freetype" DOC "Freetype includes") - - elseif() - FIND_LIBRARY(FREETYPE_LIBRARIES NAMES libfreetype PATHS "../external/freetype2/prebuilt/mac" DOC "Freetype includes") - find_path(FREETYPE_INCLUDE_DIRS ft2build.h "../external/freetype2/include/mac" "../external/freetype2/include/mac/freetype" DOC "Freetype includes") - endif(IOS) - endif(NOT FREETYPE_FOUND) - - find_package(Freetype REQUIRED) - include_directories(${FREETYPE_INCLUDE_DIRS}) - -endif() - -if(MINGW) - find_package(Freetype REQUIRED) - find_package(WebP REQUIRED) - find_package(Protobuf REQUIRED) - #find_package(MiniZip REQUIRED) - #${MINIZIP_INCLUDE_DIR} - - find_package(ZLIB REQUIRED) - - find_package(Chipmunk REQUIRED) - - message( STATUS "ZLIB dirs: ${ZLIB_INCLUDE_DIRS}") - message( STATUS "WEBP dirs: ${WEBP_INCLUDE_DIRS}") - message( STATUS "FREETYPE dirs: ${FREETYPE_INCLUDE_DIRS}") - message( STATUS "Chipmunk dirs: ${CHIPMUNK_INCLUDE_DIRS}") - message( STATUS "Protobuf dirs: ${PROTOBUF_INCLUDE_DIRS}") - - include_directories(${FREETYPE_INCLUDE_DIRS} ${WEBP_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${CHIPMUNK_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIRS}) - -else() - - #todo: provide prebuild versions of minizip for android ios mac and msvc - #done: prebuilt version for mingw-w64 (linux distros should have them also) - # check for opensuse the buildbot system arch and ubuntu - - include_directories( - ../external/unzip) - -endif() - #todo: provide prebuild versions of the xx libs for all platforms include_directories( ../external/xxhash ../external/xxtea) -add_library(cocos2d ${BUILD_TYPE} ${COCOS_SRC}) +add_library(cocos2d ${COCOS_SRC}) -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(FMOD_LIB "fmodex64") -elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(FMOD_LIB "fmodex") -endif() - -if(MINGW) - set(PLATFORM_SPECIFIC_LIBS z jpeg png webp tiff curl websockets glew32 opengl32 iconv freetype bz2) -elseif(WINDOWS) - set(PLATFORM_SPECIFIC_LIBS libjpeg libpng libwebp libtiff libcurl_imp libwebsockets freetype250 glew32 opengl32 libiconv libzlib) +set(PLATFORM_SPECIFIC_LIBS) +if(WINDOWS) + foreach(_pkg OPENGL GLEW GLFW3 VORBIS MPG123 OPENAL) + cocos_use_pkg(cocos2d ${_pkg}) + endforeach() + list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm) elseif(LINUX) - set(PLATFORM_SPECIFIC_LIBS jpeg webp tiff freetype curl websockets ssl crypto - fontconfig png pthread glfw GLEW GL X11 rt z ${FMOD_LIB}) + foreach(_pkg OPENGL GLEW GLFW3 FMODEX FONTCONFIG THREADS) + cocos_use_pkg(cocos2d ${_pkg}) + endforeach() elseif(MACOSX OR APPLE) + cocos_use_pkg(cocos2d GLFW3) + INCLUDE_DIRECTORIES ( /System/Library/Frameworks ) FIND_LIBRARY(COCOA_LIBRARY Cocoa) @@ -164,8 +111,6 @@ elseif(MACOSX OR APPLE) FIND_LIBRARY(FOUNDATION_LIBRARY Foundation) set(PLATFORM_SPECIFIC_LIBS - z jpeg png webp tiff curl - websockets freetype ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} @@ -177,17 +122,31 @@ elseif(MACOSX OR APPLE) ) elseif(ANDROID) - set(PLATFORM_SPECIFIC_LIBS GLESv2 log z android) + set(PLATFORM_SPECIFIC_LIBS GLESv2 log android) else() message( FATAL_ERROR "Unsupported platform, CMake will exit" ) endif() -# Add GLFW3 for desktop platforms -if(LINUX OR MACOSX OR WINDOWS) - list(APPEND PLATFORM_SPECIFIC_LIBS ${GLFW3_LIBRARIES}) +foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL PROTOBUF_LITE) + cocos_use_pkg(cocos2d ${pkg}) +endforeach() + +target_link_libraries(cocos2d xxhash ${PLATFORM_SPECIFIC_LIBS}) + +if(USE_WEBP) + add_definitions(-DCC_USE_WEBP=1) + cocos_use_pkg(cocos2d WEBP) +else() + add_definitions(-DCC_USE_WEBP=0) endif() -target_link_libraries(cocos2d chipmunk box2d protobuf tinyxml2 unzip xxhash ${PLATFORM_SPECIFIC_LIBS}) +if(USE_CHIPMUNK) + cocos_use_pkg(cocos2d CHIPMUNK) +endif() + +if(USE_BOX2D) + cocos_use_pkg(cocos2d Box2D) +endif() set_target_properties(cocos2d PROPERTIES diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index c2e12f8769..27437db0d4 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -7,7 +7,10 @@ if(WINDOWS) set(COCOS_AUDIO_PLATFORM_SRC audio/win32/SimpleAudioEngine.cpp audio/win32/MciPlayer.cpp - audio/win32/MciPlayer.h + audio/win32/MciPlayer.h + audio/win32/AudioEngine-win32.cpp + audio/win32/AudioCache.cpp + audio/win32/AudioPlayer.cpp ) elseif(LINUX) @@ -18,8 +21,6 @@ elseif(LINUX) audio/linux/AudioPlayer.h ) - include_directories( ../external/linux-specific/fmod/include/${ARCH_DIR} ) - elseif(MACOSX) # split it in _C and non C # because C files needs to be compiled with C compiler and not C++ @@ -45,16 +46,3 @@ elseif(MACOSX) endif() list(APPEND COCOS_AUDIO_SRC ${COCOS_AUDIO_PLATFORM_SRC}) - -if(LINUX) - if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) - set(FMOD_LIB "fmodex64") - else() - set(FMOD_LIB "fmodex") - endif() - set(AUDIO_LIB ${FMOD_LIB}) -elseif(WINDOWS) - set(AUDIO_LIB Winmm) -endif() - -include_directories( audio/include ) diff --git a/cocos/audio/openal/OpenALDecoder.h b/cocos/audio/openal/OpenALDecoder.h index aa4d00499b..b97a96be55 100644 --- a/cocos/audio/openal/OpenALDecoder.h +++ b/cocos/audio/openal/OpenALDecoder.h @@ -4,7 +4,11 @@ #include #include #include +#ifdef OPENAL_PLAIN_INCLUDES +#include +#else #include +#endif #include "cocos2d.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN diff --git a/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp b/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp index 31872e5ec7..16d95c1412 100644 --- a/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp +++ b/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp @@ -30,9 +30,15 @@ THE SOFTWARE. #include #include +#ifdef OPENAL_PLAIN_INCLUDES +#include +#include +#include +#else #include #include #include +#endif #include "OpenALDecoder.h" #ifdef ENABLE_MPG123 diff --git a/cocos/audio/win32/AudioCache.h b/cocos/audio/win32/AudioCache.h index 6f7c8bb984..9d27d7abd8 100644 --- a/cocos/audio/win32/AudioCache.h +++ b/cocos/audio/win32/AudioCache.h @@ -31,8 +31,12 @@ #include #include #include +#ifdef OPENAL_PLAIN_INCLUDES +#include +#else +#include +#endif #include "CCPlatformMacros.h" -#include "AL/al.h" #define QUEUEBUFFER_NUM 3 #define QUEUEBUFFER_TIME_STEP 0.1f diff --git a/cocos/audio/win32/AudioPlayer.h b/cocos/audio/win32/AudioPlayer.h index 8ae2019e6a..7c20ff3701 100644 --- a/cocos/audio/win32/AudioPlayer.h +++ b/cocos/audio/win32/AudioPlayer.h @@ -31,7 +31,11 @@ #include #include #include -#include "AL/al.h" +#ifdef OPENAL_PLAIN_INCLUDES +#include +#else +#include +#endif #include "CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 18575ac12b..1fb32a1379 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -447,6 +447,7 @@ void Scheduler::appendIn(_listEntry **list, const ccSchedulerFunc& callback, voi listElement->callback = callback; listElement->target = target; listElement->paused = paused; + listElement->priority = 0; listElement->markedForDeletion = false; DL_APPEND(*list, listElement); diff --git a/cocos/base/CCUserDefault-android.cpp b/cocos/base/CCUserDefault-android.cpp index c6bc9f9a57..98035c338b 100644 --- a/cocos/base/CCUserDefault-android.cpp +++ b/cocos/base/CCUserDefault-android.cpp @@ -40,7 +40,7 @@ THE SOFTWARE. #ifdef KEEP_COMPATABILITY #include "platform/CCFileUtils.h" -#include "../tinyxml2/tinyxml2.h" +#include "tinyxml2.h" #endif using namespace std; diff --git a/cocos/base/ZipUtils.cpp b/cocos/base/ZipUtils.cpp index eb2938dc22..2110643d41 100644 --- a/cocos/base/ZipUtils.cpp +++ b/cocos/base/ZipUtils.cpp @@ -24,7 +24,12 @@ ****************************************************************************/ // FIXME: hack, must be included before ziputils +#ifdef MINIZIP_FROM_SYSTEM +#include +#else // from our embedded sources #include "unzip.h" +#endif + #include "base/ZipUtils.h" #include @@ -37,7 +42,7 @@ #include // FIXME: Other platforms should use upstream minizip like mingw-w64 -#ifdef __MINGW32__ +#ifdef MINIZIP_FROM_SYSTEM #define unzGoToFirstFile64(A,B,C,D) unzGoToFirstFile2(A,B,C,D, NULL, 0, NULL, 0) #define unzGoToNextFile64(A,B,C,D) unzGoToNextFile2(A,B,C,D, NULL, 0, NULL, 0) #endif diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp index cb38bab2fd..a058cd8313 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include "2d/CCSpriteFrame.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" #include diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 488c7c6717..95bee94fc6 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -31,7 +31,7 @@ #include "cocostudio/CocoStudio.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" #include diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp index 8b1a492f29..d0d7639a6e 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp @@ -111,7 +111,7 @@ void ArmatureDataManager::removeArmatureFileInfo(const std::string& configFilePa for (std::string str : data->plistFiles) { - SpriteFrameCache::getInstance()->removeSpriteFramesFromFile(str.c_str()); + SpriteFrameCacheHelper::getInstance()->removeSpriteFrameFromFile(str); } _relativeDatas.erase(configFilePath); @@ -210,7 +210,7 @@ void ArmatureDataManager::addArmatureFileInfo(const std::string& imagePath, cons _autoLoadSpriteFile = false; DataReaderHelper::getInstance()->addDataFromFile(configFilePath); - addSpriteFrameFromFile(plistPath, imagePath); + addSpriteFrameFromFile(plistPath, imagePath, configFilePath); } void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Ref *target, SEL_SCHEDULE selector) @@ -219,7 +219,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, _autoLoadSpriteFile = false; DataReaderHelper::getInstance()->addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); - addSpriteFrameFromFile(plistPath, imagePath); + addSpriteFrameFromFile(plistPath, imagePath, configFilePath); } void ArmatureDataManager::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath) diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index d995d55c1b..43c483c919 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -26,7 +26,6 @@ THE SOFTWARE. #include "cocostudio/CCBone.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCSkin.h" -#include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCTransformHelp.h" diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 44fb5bd676..99da2e667f 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -42,7 +42,7 @@ THE SOFTWARE. #include "cocostudio/CocoLoader.h" #include "ui/CocosGUI.h" #include "CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" using namespace cocos2d; using namespace cocos2d::ui; diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index f83cdc0296..8c355bda3c 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -29,7 +29,6 @@ THE SOFTWARE. #include "cocostudio/CCSkin.h" #include "cocostudio/CCTransformHelp.h" -#include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCArmature.h" diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp index 3b7ec3f0e7..0112d0df2c 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp @@ -23,7 +23,8 @@ THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCSpriteFrameCacheHelper.h" - +#include "platform/CCFileUtils.h" +#include "2d/CCSpriteFrame.h" #include "2d/CCSpriteFrameCache.h" using namespace cocos2d; @@ -49,9 +50,53 @@ void SpriteFrameCacheHelper::purge() _spriteFrameCacheHelper = nullptr; } +void SpriteFrameCacheHelper::retainSpriteFrames(const std::string &plistPath) +{ + auto it = _usingSpriteFrames.find(plistPath); + if(it != _usingSpriteFrames.end()) return; + + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plistPath); + ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); + auto spriteFramesCache = SpriteFrameCache::getInstance(); + ValueMap& framesDict = dict["frames"].asValueMap(); + + std::vector vec; + for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter) + { + auto& spriteFrameName = iter->first; + SpriteFrame* spriteFrame = spriteFramesCache->getSpriteFrameByName(spriteFrameName); + vec.push_back(spriteFrame); + CC_SAFE_RETAIN(spriteFrame); + } + _usingSpriteFrames[plistPath] = vec; +} + +void SpriteFrameCacheHelper::releaseSpriteFrames(const std::string &plistPath) +{ + auto it = _usingSpriteFrames.find(plistPath); + if(it == _usingSpriteFrames.end()) return; + + auto& vec = it->second; + auto itFrame = vec.begin(); + while (itFrame != vec.end()) + { + CC_SAFE_RELEASE(*itFrame); + ++itFrame; + } + vec.clear(); + _usingSpriteFrames.erase(it); +} + +void SpriteFrameCacheHelper::removeSpriteFrameFromFile(const std::string &plistPath) +{ + SpriteFrameCache::getInstance()->removeSpriteFramesFromFile(plistPath); + releaseSpriteFrames(plistPath); +} + void SpriteFrameCacheHelper::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, imagePath); + retainSpriteFrames(plistPath); } SpriteFrameCacheHelper::SpriteFrameCacheHelper() diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h index 20db0f5aba..43cf661dc8 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h @@ -28,6 +28,12 @@ THE SOFTWARE. #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CocosStudioExport.h" #include +#include +#include + +namespace cocos2d { + class SpriteFrame; +} namespace cocostudio { @@ -50,11 +56,16 @@ public: * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath); + void removeSpriteFrameFromFile(const std::string& plistPath); private: + void retainSpriteFrames(const std::string& plistPath); + void releaseSpriteFrames(const std::string& plistPath); + SpriteFrameCacheHelper(); ~SpriteFrameCacheHelper(); + std::map > _usingSpriteFrames; static SpriteFrameCacheHelper *_spriteFrameCacheHelper; }; diff --git a/cocos/editor-support/cocostudio/CMakeLists.txt b/cocos/editor-support/cocostudio/CMakeLists.txt index 6dd775e1fd..51a34f89a6 100644 --- a/cocos/editor-support/cocostudio/CMakeLists.txt +++ b/cocos/editor-support/cocostudio/CMakeLists.txt @@ -1,5 +1,5 @@ -if(WINDOWS AND NOT BUILD_STATIC) +if(WINDOWS AND BUILD_SHARED_LIBS) ADD_DEFINITIONS (-D_USRSTUDIODLL) endif() diff --git a/cocos/editor-support/cocostudio/CocoStudio.h b/cocos/editor-support/cocostudio/CocoStudio.h index ba069dadd7..76df122596 100644 --- a/cocos/editor-support/cocostudio/CocoStudio.h +++ b/cocos/editor-support/cocostudio/CocoStudio.h @@ -45,7 +45,6 @@ THE SOFTWARE. #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDataReaderHelper.h" -#include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCComBase.h" diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index 25e09aed32..6112a97509 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -4,7 +4,7 @@ #include "ui/UIButton.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp index 5dcf84ada5..4a510b6f19 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp @@ -4,7 +4,7 @@ #include "ui/UICheckBox.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp index f6b00ba76c..13d50f62b1 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp @@ -4,7 +4,7 @@ #include "ui/UIImageView.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index 12a48d6dbc..d24b9734bf 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -7,7 +7,7 @@ #include "ui/UIPageView.h" #include "ui/UIListView.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp index e14384d714..38c3a5a810 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp @@ -4,7 +4,7 @@ #include "ui/UIListView.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp index 63455c819b..250cc41ae5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp @@ -4,7 +4,7 @@ #include "ui/UILoadingBar.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp index 26ed01b1f6..c2579c0580 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp @@ -5,7 +5,7 @@ #include "ui/UILayout.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp index f6294757f1..63853255c4 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp @@ -4,7 +4,7 @@ #include "ui/UIScrollView.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp index dba744e43f..e26eff0450 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp @@ -4,7 +4,7 @@ #include "ui/UISlider.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp index 3bf7b446e4..a0e4c57ccf 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp @@ -4,7 +4,7 @@ #include "ui/UITextAtlas.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp index 81c5a2a4f8..dba1177092 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp @@ -4,7 +4,7 @@ #include "ui/UITextBMFont.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp index 85115bf89d..ee71cf4f6a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp @@ -4,7 +4,7 @@ #include "ui/UITextField.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 0c08af624a..1919016c53 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -4,7 +4,7 @@ #include "ui/UIText.h" #include "cocostudio/CocoLoader.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" USING_NS_CC; using namespace ui; diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index 757df9e31a..f3ea901303 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -4,7 +4,7 @@ #include "cocostudio/CocoLoader.h" #include "ui/UIButton.h" #include "cocostudio/CSParseBinary.pb.h" -#include "tinyxml2/tinyxml2.h" +#include "tinyxml2.h" #include "../ActionTimeline/CCActionTimeline.h" USING_NS_CC; diff --git a/cocos/math/MathUtilNeon64.inl b/cocos/math/MathUtilNeon64.inl index 8e868798ef..c6fdd70b24 100644 --- a/cocos/math/MathUtilNeon64.inl +++ b/cocos/math/MathUtilNeon64.inl @@ -46,173 +46,209 @@ public: inline void MathUtilNeon64::addMatrix(const float* m, float scalar, float* dst) { - dst[0] = m[0] + scalar; - dst[1] = m[1] + scalar; - dst[2] = m[2] + scalar; - dst[3] = m[3] + scalar; - dst[4] = m[4] + scalar; - dst[5] = m[5] + scalar; - dst[6] = m[6] + scalar; - dst[7] = m[7] + scalar; - dst[8] = m[8] + scalar; - dst[9] = m[9] + scalar; - dst[10] = m[10] + scalar; - dst[11] = m[11] + scalar; - dst[12] = m[12] + scalar; - dst[13] = m[13] + scalar; - dst[14] = m[14] + scalar; - dst[15] = m[15] + scalar; + asm volatile( + "ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%1] \n\t" // M[m0-m7] M[m8-m15] + "ld1r {v4.4s}, [%2] \n\t" //ssss + + "fadd v8.4s, v0.4s, v4.4s \n\t" // DST->M[m0-m3] = M[m0-m3] + s + "fadd v9.4s, v1.4s, v4.4s \n\t" // DST->M[m4-m7] = M[m4-m7] + s + "fadd v10.4s, v2.4s, v4.4s \n\t" // DST->M[m8-m11] = M[m8-m11] + s + "fadd v11.4s, v3.4s, v4.4s \n\t" // DST->M[m12-m15] = M[m12-m15] + s + + "st4 {v8.4s, v9.4s, v10.4s, v11.4s}, [%0] \n\t" // Result in V9 + : + : "r"(dst), "r"(m), "r"(&scalar) + : "v0", "v1", "v2", "v3", "v4", "v8", "v9", "v10", "v11", "memory" + ); } inline void MathUtilNeon64::addMatrix(const float* m1, const float* m2, float* dst) { - dst[0] = m1[0] + m2[0]; - dst[1] = m1[1] + m2[1]; - dst[2] = m1[2] + m2[2]; - dst[3] = m1[3] + m2[3]; - dst[4] = m1[4] + m2[4]; - dst[5] = m1[5] + m2[5]; - dst[6] = m1[6] + m2[6]; - dst[7] = m1[7] + m2[7]; - dst[8] = m1[8] + m2[8]; - dst[9] = m1[9] + m2[9]; - dst[10] = m1[10] + m2[10]; - dst[11] = m1[11] + m2[11]; - dst[12] = m1[12] + m2[12]; - dst[13] = m1[13] + m2[13]; - dst[14] = m1[14] + m2[14]; - dst[15] = m1[15] + m2[15]; + asm volatile( + "ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%1] \n\t" // M1[m0-m7] M1[m8-m15] + "ld4 {v8.4s, v9.4s, v10.4s, v11.4s}, [%2] \n\t" // M2[m0-m7] M2[m8-m15] + + "fadd v12.4s, v0.4s, v8.4s \n\t" // DST->M[m0-m3] = M1[m0-m3] + M2[m0-m3] + "fadd v13.4s, v1.4s, v9.4s \n\t" // DST->M[m4-m7] = M1[m4-m7] + M2[m4-m7] + "fadd v14.4s, v2.4s, v10.4s \n\t" // DST->M[m8-m11] = M1[m8-m11] + M2[m8-m11] + "fadd v15.4s, v3.4s, v11.4s \n\t" // DST->M[m12-m15] = M1[m12-m15] + M2[m12-m15] + + "st4 {v12.4s, v13.4s, v14.4s, v15.4s}, [%0] \n\t" // DST->M[m0-m7] DST->M[m8-m15] + : + : "r"(dst), "r"(m1), "r"(m2) + : "v0", "v1", "v2", "v3", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", "memory" + ); } inline void MathUtilNeon64::subtractMatrix(const float* m1, const float* m2, float* dst) { - dst[0] = m1[0] - m2[0]; - dst[1] = m1[1] - m2[1]; - dst[2] = m1[2] - m2[2]; - dst[3] = m1[3] - m2[3]; - dst[4] = m1[4] - m2[4]; - dst[5] = m1[5] - m2[5]; - dst[6] = m1[6] - m2[6]; - dst[7] = m1[7] - m2[7]; - dst[8] = m1[8] - m2[8]; - dst[9] = m1[9] - m2[9]; - dst[10] = m1[10] - m2[10]; - dst[11] = m1[11] - m2[11]; - dst[12] = m1[12] - m2[12]; - dst[13] = m1[13] - m2[13]; - dst[14] = m1[14] - m2[14]; - dst[15] = m1[15] - m2[15]; + asm volatile( + "ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%1] \n\t" // M1[m0-m7] M1[m8-m15] + "ld4 {v8.4s, v9.4s, v10.4s, v11.4s}, [%2] \n\t" // M2[m0-m7] M2[m8-m15] + + "fsub v12.4s, v0.4s, v8.4s \n\t" // DST->M[m0-m3] = M1[m0-m3] - M2[m0-m3] + "fsub v13.4s, v1.4s, v9.4s \n\t" // DST->M[m4-m7] = M1[m4-m7] - M2[m4-m7] + "fsub v14.4s, v2.4s, v10.4s \n\t" // DST->M[m8-m11] = M1[m8-m11] - M2[m8-m11] + "fsub v15.4s, v3.4s, v11.4s \n\t" // DST->M[m12-m15] = M1[m12-m15] - M2[m12-m15] + + "st4 {v12.4s, v13.4s, v14.4s, v15.4s}, [%0] \n\t" // DST->M[m0-m7] DST->M[m8-m15] + : + : "r"(dst), "r"(m1), "r"(m2) + : "v0", "v1", "v2", "v3", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", "memory" + ); } inline void MathUtilNeon64::multiplyMatrix(const float* m, float scalar, float* dst) { - dst[0] = m[0] * scalar; - dst[1] = m[1] * scalar; - dst[2] = m[2] * scalar; - dst[3] = m[3] * scalar; - dst[4] = m[4] * scalar; - dst[5] = m[5] * scalar; - dst[6] = m[6] * scalar; - dst[7] = m[7] * scalar; - dst[8] = m[8] * scalar; - dst[9] = m[9] * scalar; - dst[10] = m[10] * scalar; - dst[11] = m[11] * scalar; - dst[12] = m[12] * scalar; - dst[13] = m[13] * scalar; - dst[14] = m[14] * scalar; - dst[15] = m[15] * scalar; + asm volatile( + "ld1 {v0.s}[0], [%2] \n\t" //s + "ld4 {v4.4s, v5.4s, v6.4s, v7.4s}, [%1] \n\t" //M[m0-m7] M[m8-m15] + + "fmul v8.4s, v4.4s, v0.s[0] \n\t" // DST->M[m0-m3] = M[m0-m3] * s + "fmul v9.4s, v5.4s, v0.s[0] \n\t" // DST->M[m4-m7] = M[m4-m7] * s + "fmul v10.4s, v6.4s, v0.s[0] \n\t" // DST->M[m8-m11] = M[m8-m11] * s + "fmul v11.4s, v7.4s, v0.s[0] \n\t" // DST->M[m12-m15] = M[m12-m15] * s + + "st4 {v8.4s, v9.4s, v10.4s, v11.4s}, [%0] \n\t" // DST->M[m0-m7] DST->M[m8-m15] + : + : "r"(dst), "r"(m), "r"(&scalar) + : "v0", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "memory" + ); } inline void MathUtilNeon64::multiplyMatrix(const float* m1, const float* m2, float* dst) { - // Support the case where m1 or m2 is the same array as dst. - float product[16]; - - product[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; - product[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; - product[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; - product[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; - - product[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; - product[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; - product[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; - product[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; - - product[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; - product[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; - product[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; - product[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; - - product[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; - product[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; - product[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; - product[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; - - memcpy(dst, product, MATRIX_SIZE); + asm volatile( + "ld1 {v8.4s, v9.4s, v10.4s, v11.4s}, [%1] \n\t" // M1[m0-m7] M1[m8-m15] M2[m0-m7] M2[m8-m15] + "ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%2] \n\t" // M2[m0-m15] + + + "fmul v12.4s, v8.4s, v0.s[0] \n\t" // DST->M[m0-m3] = M1[m0-m3] * M2[m0] + "fmul v13.4s, v8.4s, v0.s[1] \n\t" // DST->M[m4-m7] = M1[m4-m7] * M2[m4] + "fmul v14.4s, v8.4s, v0.s[2] \n\t" // DST->M[m8-m11] = M1[m8-m11] * M2[m8] + "fmul v15.4s, v8.4s, v0.s[3] \n\t" // DST->M[m12-m15] = M1[m12-m15] * M2[m12] + + "fmla v12.4s, v9.4s, v1.s[0] \n\t" // DST->M[m0-m3] += M1[m0-m3] * M2[m1] + "fmla v13.4s, v9.4s, v1.s[1] \n\t" // DST->M[m4-m7] += M1[m4-m7] * M2[m5] + "fmla v14.4s, v9.4s, v1.s[2] \n\t" // DST->M[m8-m11] += M1[m8-m11] * M2[m9] + "fmla v15.4s, v9.4s, v1.s[3] \n\t" // DST->M[m12-m15] += M1[m12-m15] * M2[m13] + + "fmla v12.4s, v10.4s, v2.s[0] \n\t" // DST->M[m0-m3] += M1[m0-m3] * M2[m2] + "fmla v13.4s, v10.4s, v2.s[1] \n\t" // DST->M[m4-m7] += M1[m4-m7] * M2[m6] + "fmla v14.4s, v10.4s, v2.s[2] \n\t" // DST->M[m8-m11] += M1[m8-m11] * M2[m10] + "fmla v15.4s, v10.4s, v2.s[3] \n\t" // DST->M[m12-m15] += M1[m12-m15] * M2[m14] + + "fmla v12.4s, v11.4s, v3.s[0] \n\t" // DST->M[m0-m3] += M1[m0-m3] * M2[m3] + "fmla v13.4s, v11.4s, v3.s[1] \n\t" // DST->M[m4-m7] += M1[m4-m7] * M2[m7] + "fmla v14.4s, v11.4s, v3.s[2] \n\t" // DST->M[m8-m11] += M1[m8-m11] * M2[m11] + "fmla v15.4s, v11.4s, v3.s[3] \n\t" // DST->M[m12-m15] += M1[m12-m15] * M2[m15] + + "st1 {v12.4s, v13.4s, v14.4s, v15.4s}, [%0] \n\t" // DST->M[m0-m7]// DST->M[m8-m15] + + : // output + : "r"(dst), "r"(m1), "r"(m2) // input - note *value* of pointer doesn't change. + : "memory", "v0", "v1", "v2", "v3", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15" + ); } inline void MathUtilNeon64::negateMatrix(const float* m, float* dst) { - dst[0] = -m[0]; - dst[1] = -m[1]; - dst[2] = -m[2]; - dst[3] = -m[3]; - dst[4] = -m[4]; - dst[5] = -m[5]; - dst[6] = -m[6]; - dst[7] = -m[7]; - dst[8] = -m[8]; - dst[9] = -m[9]; - dst[10] = -m[10]; - dst[11] = -m[11]; - dst[12] = -m[12]; - dst[13] = -m[13]; - dst[14] = -m[14]; - dst[15] = -m[15]; + asm volatile( + "ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%1] \n\t" // load m0-m7 load m8-m15 + + "fneg v4.4s, v0.4s \n\t" // negate m0-m3 + "fneg v5.4s, v1.4s \n\t" // negate m4-m7 + "fneg v6.4s, v2.4s \n\t" // negate m8-m15 + "fneg v7.4s, v3.4s \n\t" // negate m8-m15 + + "st4 {v4.4s, v5.4s, v6.4s, v7.4s}, [%0] \n\t" // store m0-m7 store m8-m15 + : + : "r"(dst), "r"(m) + : "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "memory" + ); } inline void MathUtilNeon64::transposeMatrix(const float* m, float* dst) { - float t[16] = { - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15] - }; - memcpy(dst, t, MATRIX_SIZE); + asm volatile( + "ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%1] \n\t" // DST->M[m0, m4, m8, m12] = M[m0-m3] + //DST->M[m1, m5, m9, m12] = M[m4-m7] + "st1 {v0.4s, v1.4s, v2.4s, v3.4s}, [%0] \n\t" + : + : "r"(dst), "r"(m) + : "v0", "v1", "v2", "v3", "memory" + ); } inline void MathUtilNeon64::transformVec4(const float* m, float x, float y, float z, float w, float* dst) { - dst[0] = x * m[0] + y * m[4] + z * m[8] + w * m[12]; - dst[1] = x * m[1] + y * m[5] + z * m[9] + w * m[13]; - dst[2] = x * m[2] + y * m[6] + z * m[10] + w * m[14]; + asm volatile( + "ld1 {v0.s}[0], [%1] \n\t" // V[x] + "ld1 {v0.s}[1], [%2] \n\t" // V[y] + "ld1 {v0.s}[2], [%3] \n\t" // V[z] + "ld1 {v0.s}[3], [%4] \n\t" // V[w] + "ld1 {v9.4s, v10.4s, v11.4s, v12.4s}, [%5] \n\t" // M[m0-m7] M[m8-m15] + + + "fmul v13.4s, v9.4s, v0.s[0] \n\t" // DST->V = M[m0-m3] * V[x] + "fmla v13.4s, v10.4s, v0.s[1] \n\t" // DST->V += M[m4-m7] * V[y] + "fmla v13.4s, v11.4s, v0.s[2] \n\t" // DST->V += M[m8-m11] * V[z] + "fmla v13.4s, v12.4s, v0.s[3] \n\t" // DST->V += M[m12-m15] * V[w] + + //"st1 {v13.4s}, [%0] \n\t" // DST->V[x, y] // DST->V[z] + "st1 {v13.2s}, [%0], 8 \n\t" + "st1 {v13.s}[2], [%0] \n\t" + : + : "r"(dst), "r"(&x), "r"(&y), "r"(&z), "r"(&w), "r"(m) + : "v0", "v9", "v10","v11", "v12", "v13", "memory" + ); } inline void MathUtilNeon64::transformVec4(const float* m, const float* v, float* dst) { - // Handle case where v == dst. - float x = v[0] * m[0] + v[1] * m[4] + v[2] * m[8] + v[3] * m[12]; - float y = v[0] * m[1] + v[1] * m[5] + v[2] * m[9] + v[3] * m[13]; - float z = v[0] * m[2] + v[1] * m[6] + v[2] * m[10] + v[3] * m[14]; - float w = v[0] * m[3] + v[1] * m[7] + v[2] * m[11] + v[3] * m[15]; - - dst[0] = x; - dst[1] = y; - dst[2] = z; - dst[3] = w; + asm volatile + ( + "ld1 {v0.4s}, [%1] \n\t" // V[x, y, z, w] + "ld1 {v9.4s, v10.4s, v11.4s, v12.4s}, [%2] \n\t" // M[m0-m7] M[m8-m15] + + "fmul v13.4s, v9.4s, v0.s[0] \n\t" // DST->V = M[m0-m3] * V[x] + "fmla v13.4s, v10.4s, v0.s[1] \n\t" // DST->V = M[m4-m7] * V[y] + "fmla v13.4s, v11.4s, v0.s[2] \n\t" // DST->V = M[m8-m11] * V[z] + "fmla v13.4s, v12.4s, v0.s[3] \n\t" // DST->V = M[m12-m15] * V[w] + + "st1 {v13.4s}, [%0] \n\t" // DST->V + : + : "r"(dst), "r"(v), "r"(m) + : "v0", "v9", "v10","v11", "v12", "v13", "memory" + ); } inline void MathUtilNeon64::crossVec3(const float* v1, const float* v2, float* dst) { - float x = (v1[1] * v2[2]) - (v1[2] * v2[1]); - float y = (v1[2] * v2[0]) - (v1[0] * v2[2]); - float z = (v1[0] * v2[1]) - (v1[1] * v2[0]); - - dst[0] = x; - dst[1] = y; - dst[2] = z; + asm volatile( + "ld1 {v0.2s}, [%2] \n\t" // + "ld1 {v0.s}[3], [%1] \n\t" // + "mov v0.s[2], v0.s[1] \n\t" // q0 = (v1y, v1z, v1z, v1x) + + "ld1 {v1.s}[1], [%3] \n\t" // + "ld1 {v1.s}[2], [%4], 4 \n\t" // + "ld1 {v1.s}[3], [%4] \n\t" // + "mov v1.s[0], v1.s[3] \n\t" // q1 = (v2z, v2x, v2y, v2z) + + "fmul v2.4s, v0.4s, v1.4s \n\t" // x = v1y * v2z, y = v1z * v2x + "fsub s8, s8, s10 \n\t" + "fsub s9, s9, s11 \n\t" // x -= v1z * v2y, y-= v1x - v2z + + "fmul s10, s3, s6 \n\t" // z = v1x * v2y + "fmul s11, s0, s5 \n\t" // z-= v1y * vx + "fsub s10, s10, s11 \n\t" + + "st1 {v2.2s}, [%0], 8 \n\t" // V[x, y] + "st1 {v2.s}[2], [%0] \n\t" // V[z] + : + : "r"(dst), "r"(v1), "r"((v1+1)), "r"(v2), "r"((v2+1)) + : "v0", "v1", "v2", "memory" + ); } NS_CC_MATH_END diff --git a/cocos/network/HttpClient.cpp b/cocos/network/HttpClient.cpp index 9bcd92df1c..88e4478665 100644 --- a/cocos/network/HttpClient.cpp +++ b/cocos/network/HttpClient.cpp @@ -32,12 +32,12 @@ #include +#include + #include "base/CCVector.h" #include "base/CCDirector.h" #include "base/CCScheduler.h" -#include "curl/curl.h" - #include "platform/CCFileUtils.h" NS_CC_BEGIN diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index 1d17d4fca8..c9723d12f7 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -34,7 +34,11 @@ THE SOFTWARE. #include "base/ccUtils.h" #include "tinyxml2.h" +#ifdef MINIZIP_FROM_SYSTEM +#include +#else // from our embedded sources #include "unzip.h" +#endif #include #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) @@ -443,7 +447,6 @@ static tinyxml2::XMLElement* generateElementForObject(const Value& value, tinyxm return node; } - // object is Array if (value.getType() == Value::Type::VECTOR) return generateElementForArray(value.asValueVector(), doc); @@ -463,14 +466,14 @@ static tinyxml2::XMLElement* generateElementForDict(const ValueMap& dict, tinyxm { tinyxml2::XMLElement* rootNode = doc->NewElement("dict"); - for (auto iter = dict.cbegin(); iter != dict.cend(); ++iter) + for (const auto &iter : dict) { tinyxml2::XMLElement* tmpNode = doc->NewElement("key"); rootNode->LinkEndChild(tmpNode); - tinyxml2::XMLText* content = doc->NewText(iter->first.c_str()); + tinyxml2::XMLText* content = doc->NewText(iter.first.c_str()); tmpNode->LinkEndChild(content); - tinyxml2::XMLElement *element = generateElementForObject(iter->second, doc); + tinyxml2::XMLElement *element = generateElementForObject(iter.second, doc); if (element) rootNode->LinkEndChild(element); } @@ -492,7 +495,6 @@ static tinyxml2::XMLElement* generateElementForArray(const ValueVector& array, t return rootNode; } - #else NS_CC_BEGIN @@ -504,10 +506,8 @@ bool FileUtils::writeToFile(ValueMap& dict, const std::string &fullPath) {return #endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */ - FileUtils* FileUtils::s_sharedFileUtils = nullptr; - void FileUtils::destroyInstance() { CC_SAFE_DELETE(s_sharedFileUtils); @@ -521,7 +521,6 @@ FileUtils::~FileUtils() { } - bool FileUtils::init() { _searchPathArray.push_back(_defaultResRootPath); @@ -546,6 +545,7 @@ static Data getData(const std::string& filename, bool forString) size_t size = 0; size_t readsize; const char* mode = nullptr; + if (forString) mode = "rt"; else @@ -629,7 +629,7 @@ unsigned char* FileUtils::getFileData(const std::string& filename, const char* m fclose(fp); } while (0); - if (! buffer) + if (!buffer) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); @@ -653,7 +653,7 @@ unsigned char* FileUtils::getFileDataFromZip(const std::string& zipFilePath, con CC_BREAK_IF(!file); // FIXME: Other platforms should use upstream minizip like mingw-w64 - #ifdef __MINGW32__ + #ifdef MINIZIP_FROM_SYSTEM int ret = unzLocateFile(file, filename.c_str(), NULL); #else int ret = unzLocateFile(file, filename.c_str(), 1); @@ -724,7 +724,6 @@ std::string FileUtils::getPathForFilename(const std::string& filename, const std return path; } - std::string FileUtils::fullPathForFilename(const std::string &filename) { if (filename.empty()) @@ -739,7 +738,7 @@ std::string FileUtils::fullPathForFilename(const std::string &filename) // Already Cached ? auto cacheIter = _fullPathCache.find(filename); - if( cacheIter != _fullPathCache.end() ) + if(cacheIter != _fullPathCache.end()) { return cacheIter->second; } @@ -749,11 +748,11 @@ std::string FileUtils::fullPathForFilename(const std::string &filename) std::string fullpath; - for (auto searchIt = _searchPathArray.cbegin(); searchIt != _searchPathArray.cend(); ++searchIt) + for (const auto& searchIt : _searchPathArray) { - for (auto resolutionIt = _searchResolutionsOrderArray.cbegin(); resolutionIt != _searchResolutionsOrderArray.cend(); ++resolutionIt) + for (const auto& resolutionIt : _searchResolutionsOrderArray) { - fullpath = this->getPathForFilename(newFilename, *resolutionIt, *searchIt); + fullpath = this->getPathForFilename(newFilename, resolutionIt, searchIt); if (fullpath.length() > 0) { @@ -761,6 +760,7 @@ std::string FileUtils::fullPathForFilename(const std::string &filename) _fullPathCache.insert(std::make_pair(filename, fullpath)); return fullpath; } + } } @@ -783,9 +783,9 @@ void FileUtils::setSearchResolutionsOrder(const std::vector& search bool existDefault = false; _fullPathCache.clear(); _searchResolutionsOrderArray.clear(); - for(auto iter = searchResolutionsOrder.cbegin(); iter != searchResolutionsOrder.cend(); ++iter) + for(const auto& iter : searchResolutionsOrder) { - std::string resolutionDirectory = *iter; + std::string resolutionDirectory = iter; if (!existDefault && resolutionDirectory == "") { existDefault = true; @@ -798,6 +798,7 @@ void FileUtils::setSearchResolutionsOrder(const std::vector& search _searchResolutionsOrderArray.push_back(resolutionDirectory); } + if (!existDefault) { _searchResolutionsOrderArray.push_back(""); @@ -809,6 +810,7 @@ void FileUtils::addSearchResolutionsOrder(const std::string &order,const bool fr std::string resOrder = order; if (!resOrder.empty() && resOrder[resOrder.length()-1] != '/') resOrder.append("/"); + if (front) { _searchResolutionsOrderArray.insert(_searchResolutionsOrderArray.begin(), resOrder); } else { @@ -816,7 +818,7 @@ void FileUtils::addSearchResolutionsOrder(const std::string &order,const bool fr } } -const std::vector& FileUtils::getSearchResolutionsOrder() +const std::vector& FileUtils::getSearchResolutionsOrder() const { return _searchResolutionsOrderArray; } @@ -832,16 +834,16 @@ void FileUtils::setSearchPaths(const std::vector& searchPaths) _fullPathCache.clear(); _searchPathArray.clear(); - for (auto iter = searchPaths.cbegin(); iter != searchPaths.cend(); ++iter) + for (const auto& iter : searchPaths) { std::string prefix; std::string path; - if (!isAbsolutePath(*iter)) + if (!isAbsolutePath(iter)) { // Not an absolute path prefix = _defaultResRootPath; } - path = prefix + (*iter); + path = prefix + (iter); if (path.length() > 0 && path[path.length()-1] != '/') { path += "/"; @@ -1005,12 +1007,12 @@ bool FileUtils::isDirectoryExist(const std::string& dirPath) } std::string fullpath; - for (auto searchIt = _searchPathArray.cbegin(); searchIt != _searchPathArray.cend(); ++searchIt) + for (const auto& searchIt : _searchPathArray) { - for (auto resolutionIt = _searchResolutionsOrderArray.cbegin(); resolutionIt != _searchResolutionsOrderArray.cend(); ++resolutionIt) + for (const auto& resolutionIt : _searchResolutionsOrderArray) { // searchPath + file_path + resourceDirectory - fullpath = *searchIt + dirPath + *resolutionIt; + fullpath = searchIt + dirPath + resolutionIt; if (isDirectoryExistInternal(fullpath)) { const_cast(this)->_fullPathCache.insert(std::make_pair(dirPath, fullpath)); diff --git a/cocos/platform/CCFileUtils.h b/cocos/platform/CCFileUtils.h index ee097a3c53..2323d222b5 100644 --- a/cocos/platform/CCFileUtils.h +++ b/cocos/platform/CCFileUtils.h @@ -238,7 +238,7 @@ public: * @since v2.1 * @lua NA */ - virtual const std::vector& getSearchResolutionsOrder(); + virtual const std::vector& getSearchResolutionsOrder() const; /** * Sets the array of search paths. diff --git a/cocos/platform/apple/CCFileUtils-apple.mm b/cocos/platform/apple/CCFileUtils-apple.mm index ae81af2b7e..5ebd81f730 100644 --- a/cocos/platform/apple/CCFileUtils-apple.mm +++ b/cocos/platform/apple/CCFileUtils-apple.mm @@ -35,8 +35,6 @@ THE SOFTWARE. #include "deprecated/CCDictionary.h" #include "platform/CCFileUtils.h" #include "platform/CCSAXParser.h" -#include "unzip.h" - NS_CC_BEGIN diff --git a/cocos/platform/win8.1-universal/OpenGLES.cpp b/cocos/platform/win8.1-universal/OpenGLES.cpp index 943b0856fc..3f696abba7 100644 --- a/cocos/platform/win8.1-universal/OpenGLES.cpp +++ b/cocos/platform/win8.1-universal/OpenGLES.cpp @@ -48,51 +48,107 @@ void OpenGLES::Initialize() EGL_NONE }; - const EGLint displayAttributes[] = - { - // This can be used to configure D3D11. For example, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE could be used. - // This would ask the graphics card to use D3D11 Feature Level 9_3 instead of Feature Level 11_0+. - // On Windows Phone, this would allow the Phone Emulator to act more like the GPUs that are available on real Phone devices. -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE, - EGL_NONE, -#else - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_NONE, -#endif - }; - const EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - // eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in 'displayAttributes' to configure D3D11. + const EGLint defaultDisplayAttributes[] = + { + // These are the default display attributes, used to request ANGLE's D3D11 renderer. + // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + + // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. + // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE, + }; + + const EGLint fl9_3DisplayAttributes[] = + { + // These can be used to request ANGLE's D3D11 renderer, with D3D11 Feature Level 9_3. + // These attributes are used if the call to eglInitialize fails with the default display attributes. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, + EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE, + }; + + const EGLint warpDisplayAttributes[] = + { + // These attributes can be used to request D3D11 WARP. + // They are used if eglInitialize fails with both the default display attributes and the 9_3 display attributes. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_TRUE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE, + }; + + EGLConfig config = NULL; + + // eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in display attributes, used to configure D3D11. PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast(eglGetProcAddress("eglGetPlatformDisplayEXT")); if (!eglGetPlatformDisplayEXT) { throw Exception::CreateException(E_FAIL, L"Failed to get function eglGetPlatformDisplayEXT"); } - mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes); + // + // To initialize the display, we make three sets of calls to eglGetPlatformDisplayEXT and eglInitialize, with varying + // parameters passed to eglGetPlatformDisplayEXT: + // 1) The first calls uses "defaultDisplayAttributes" as a parameter. This corresponds to D3D11 Feature Level 10_0+. + // 2) If eglInitialize fails for step 1 (e.g. because 10_0+ isn't supported by the default GPU), then we try again + // using "fl9_3DisplayAttributes". This corresponds to D3D11 Feature Level 9_3. + // 3) If eglInitialize fails for step 2 (e.g. because 9_3+ isn't supported by the default GPU), then we try again + // using "warpDisplayAttributes". This corresponds to D3D11 Feature Level 11_0 on WARP, a D3D11 software rasterizer. + // + // Note: On Windows Phone, we #ifdef out the first set of calls to eglPlatformDisplayEXT and eglInitialize. + // Windows Phones devices only support D3D11 Feature Level 9_3, but the Windows Phone emulator supports 11_0+. + // We use this #ifdef to limit the Phone emulator to Feature Level 9_3, making it behave more like + // real Windows Phone devices. + // If you wish to test Feature Level 10_0+ in the Windows Phone emulator then you should remove this #ifdef. + // + +#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) + // This tries to initialize EGL to D3D11 Feature Level 10_0+. See above comment for details. + mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); if (mEglDisplay == EGL_NO_DISPLAY) { - throw Exception::CreateException(E_FAIL, L"Failed to get default EGL display"); + throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); } if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) +#endif { - throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); + // This tries to initialize EGL to D3D11 Feature Level 9_3, if 10_0+ is unavailable (e.g. on Windows Phone, or certain Windows tablets). + mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); + if (mEglDisplay == EGL_NO_DISPLAY) + { + throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); + } + + if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) + { + // This initializes EGL to D3D11 Feature Level 11_0 on WARP, if 9_3+ is unavailable on the default GPU (e.g. on Surface RT). + mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes); + if (mEglDisplay == EGL_NO_DISPLAY) + { + throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); + } + + if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) + { + // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. + throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); + } + } } EGLint numConfigs = 0; - if (eglGetConfigs(mEglDisplay, NULL, 0, &numConfigs) == EGL_FALSE) - { - throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count"); - } - - if (eglChooseConfig(mEglDisplay, configAttributes, &mEglConfig, 1, &numConfigs) == EGL_FALSE) + if ((eglChooseConfig(mEglDisplay, configAttributes, &mEglConfig, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0)) { throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig"); } @@ -134,6 +190,14 @@ EGLSurface OpenGLES::CreateSurface(SwapChainPanel^ panel, const Size* renderSurf EGLSurface surface = EGL_NO_SURFACE; + const EGLint surfaceAttributes[] = + { + // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). + // If you have compilation issues with it then please update your Visual Studio templates. + EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE + }; + // Create a PropertySet and initialize with the EGLNativeWindowType. PropertySet^ surfaceCreationProperties = ref new PropertySet(); surfaceCreationProperties->Insert(ref new String(EGLNativeWindowTypeProperty), panel); @@ -144,7 +208,7 @@ EGLSurface OpenGLES::CreateSurface(SwapChainPanel^ panel, const Size* renderSurf surfaceCreationProperties->Insert(ref new String(EGLRenderSurfaceSizeProperty), PropertyValue::CreateSize(*renderSurfaceSize)); } - surface = eglCreateWindowSurface(mEglDisplay, mEglConfig, reinterpret_cast(surfaceCreationProperties), NULL); + surface = eglCreateWindowSurface(mEglDisplay, mEglConfig, reinterpret_cast(surfaceCreationProperties), surfaceAttributes); if (surface == EGL_NO_SURFACE) { throw Exception::CreateException(E_FAIL, L"Failed to create EGL surface"); diff --git a/cocos/platform/win8.1-universal/OpenGLES.h b/cocos/platform/win8.1-universal/OpenGLES.h index ce9f2a9cdf..1a57b68739 100644 --- a/cocos/platform/win8.1-universal/OpenGLES.h +++ b/cocos/platform/win8.1-universal/OpenGLES.h @@ -28,7 +28,6 @@ #include #include - class OpenGLES { public: diff --git a/cocos/platform/winrt/CCDevice.cpp b/cocos/platform/winrt/CCDevice.cpp index e3f7edbde5..71a6ff303a 100644 --- a/cocos/platform/winrt/CCDevice.cpp +++ b/cocos/platform/winrt/CCDevice.cpp @@ -100,6 +100,7 @@ void Device::setAccelerometerEnabled(bool isEnabled) auto orientation = GLViewImpl::sharedOpenGLView()->getDeviceOrientation(); +#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) switch (orientation) { case DisplayOrientations::Portrait: @@ -127,7 +128,36 @@ void Device::setAccelerometerEnabled(bool isEnabled) acc.y = reading->AccelerationY; break; } +#else // Windows Store App + // from http://msdn.microsoft.com/en-us/library/windows/apps/dn440593 + switch (orientation) + { + case DisplayOrientations::Portrait: + acc.x = reading->AccelerationY; + acc.y = -reading->AccelerationX; + break; + case DisplayOrientations::Landscape: + acc.x = reading->AccelerationX; + acc.y = reading->AccelerationY; + break; + + case DisplayOrientations::PortraitFlipped: + acc.x = -reading->AccelerationY; + acc.y = reading->AccelerationX; + break; + + case DisplayOrientations::LandscapeFlipped: + acc.x = -reading->AccelerationY; + acc.y = reading->AccelerationX; + break; + + default: + acc.x = reading->AccelerationY; + acc.y = -reading->AccelerationX; + break; + } +#endif std::shared_ptr event(new AccelerometerEvent(acc)); cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(event); }); diff --git a/cocos/platform/wp8/CCGLViewImpl-wp8.cpp b/cocos/platform/wp8/CCGLViewImpl-wp8.cpp index 6c6835aecc..8c06803118 100644 --- a/cocos/platform/wp8/CCGLViewImpl-wp8.cpp +++ b/cocos/platform/wp8/CCGLViewImpl-wp8.cpp @@ -179,6 +179,11 @@ bool GLViewImpl::isOpenGLReady() void GLViewImpl::end() { m_windowClosed = true; + std::string str; + if (m_delegate) { + // Terminate app on Director::getInstance()->end(); + m_delegate->Invoke(Cocos2dEvent::TerminateApp, stringToPlatformString(str)); + } } @@ -193,11 +198,8 @@ void GLViewImpl::OnResuming(Platform::Object^ sender, Platform::Object^ args) // user pressed the Back Key on the phone void GLViewImpl::OnBackKeyPress() { - std::string str; - if(m_delegate) - { - m_delegate->Invoke(Cocos2dEvent::TerminateApp, stringToPlatformString(str)); - } + EventKeyboard event(EventKeyboard::KeyCode::KEY_ESCAPE, false); + Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } void GLViewImpl::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index 3becd4f99f..22084d136f 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -1,4 +1,8 @@ -set(cocos_root ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(cocos_root ${Cocos2d-X_SOURCE_DIR}) + +if(WINDOWS) + add_definitions(-DLUASOCKET_INET_ATON -DLUASOCKET_INET_PTON) +endif() include_directories( ${cocos_root}/external/lua/tolua @@ -17,13 +21,12 @@ include_directories( ${cocos_root}/cocos/editor-support ${cocos_root}/cocos/platform ${cocos_root}/cocos/audio/include - ${CMAKE_CURRENT_SOURCE_DIR}/manual - ${CMAKE_CURRENT_SOURCE_DIR}/manual/extension - ${CMAKE_CURRENT_SOURCE_DIR}/manual/cocostudio - ${CMAKE_CURRENT_SOURCE_DIR}/manual/ui - ${CMAKE_CURRENT_SOURCE_DIR}/ui - ${CMAKE_CURRENT_SOURCE_DIR}/manual/cocos2d - ${CMAKE_CURRENT_SOURCE_DIR}/auto + manual + manual/extension + manual/cocostudio + manual/ui + manual/cocos2d + auto ) file(GLOB lua_cocos2d_source_files @@ -32,25 +35,32 @@ file(GLOB lua_cocos2d_source_files "${cocos_root}/external/xxtea/xxtea.cpp" ) -# luasockets are needed in Linux too, -# but Linux have them disabled for some reason -if(MACOSX) - set(lua_cocos2d_source_files - ${lua_cocos2d_source_files} - ${cocos_root}/external/lua/luasocket/auxiliar.c - ${cocos_root}/external/lua/luasocket/buffer.c - ${cocos_root}/external/lua/luasocket/except.c - ${cocos_root}/external/lua/luasocket/inet.c - ${cocos_root}/external/lua/luasocket/io.c +list(APPEND lua_cocos2d_source_files ${cocos_root}/external/lua/luasocket/luasocket.c - ${cocos_root}/external/lua/luasocket/luasocket_scripts.c - ${cocos_root}/external/lua/luasocket/mime.c - ${cocos_root}/external/lua/luasocket/options.c - ${cocos_root}/external/lua/luasocket/select.c - ${cocos_root}/external/lua/luasocket/serial.c - ${cocos_root}/external/lua/luasocket/tcp.c ${cocos_root}/external/lua/luasocket/timeout.c + ${cocos_root}/external/lua/luasocket/buffer.c + ${cocos_root}/external/lua/luasocket/io.c + ${cocos_root}/external/lua/luasocket/auxiliar.c + ${cocos_root}/external/lua/luasocket/options.c + ${cocos_root}/external/lua/luasocket/inet.c + ${cocos_root}/external/lua/luasocket/except.c + ${cocos_root}/external/lua/luasocket/select.c + ${cocos_root}/external/lua/luasocket/tcp.c ${cocos_root}/external/lua/luasocket/udp.c + ${cocos_root}/external/lua/luasocket/mime.c + ${cocos_root}/external/lua/luasocket/luasocket_scripts.c + ) + +if(WINDOWS) + list(APPEND lua_cocos2d_source_files + ${cocos_root}/external/lua/luasocket/wsocket.c + ) +elseif(UNIX) + if(LINUX) + add_definitions(-D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE) + endif() + list(APPEND lua_cocos2d_source_files + ${cocos_root}/external/lua/luasocket/serial.c ${cocos_root}/external/lua/luasocket/unix.c ${cocos_root}/external/lua/luasocket/usocket.c ) @@ -116,7 +126,7 @@ endif() set(lua_bindings_files ${lua_cocos2d_source_files} ${lua_bindings_manual_files} ${lua_bindings_auto_files}) -add_library(luacocos2d STATIC ${lua_bindings_files}) +add_library(luacocos2d ${lua_bindings_files}) target_link_libraries(luacocos2d cocos2d) set_target_properties(luacocos2d PROPERTIES diff --git a/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua b/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua index 6f7f27e934..443df5e28b 100644 --- a/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua @@ -5,10 +5,11 @@ -- @parent_module cc -------------------------------- --- Inverted. If this is set to true,
--- the stencil is inverted, so the content is drawn where the stencil is NOT drawn.
--- This default to false. --- @function [parent=#ClippingNode] isInverted +-- If stencil has no childre it will not be drawn.
+-- If you have custom stencil-based node with stencil drawing mechanics other then children-based,
+-- then this method should return true every time you wish stencil to be visited.
+-- By default returns true if has any children attached. +-- @function [parent=#ClippingNode] hasContent -- @param self -- @return bool#bool ret (return value: bool) @@ -47,6 +48,14 @@ -- @param self -- @param #float alphaThreshold +-------------------------------- +-- Inverted. If this is set to true,
+-- the stencil is inverted, so the content is drawn where the stencil is NOT drawn.
+-- This default to false. +-- @function [parent=#ClippingNode] isInverted +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- @overload self, cc.Node -- @overload self diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index d795a814d0..365625d98d 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -44340,7 +44340,7 @@ int lua_register_cocos2dx_Menu(lua_State* tolua_S) return 1; } -int lua_cocos2dx_ClippingNode_isInverted(lua_State* tolua_S) +int lua_cocos2dx_ClippingNode_hasContent(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; @@ -44360,7 +44360,7 @@ int lua_cocos2dx_ClippingNode_isInverted(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_isInverted'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_hasContent'", nullptr); return 0; } #endif @@ -44370,16 +44370,16 @@ int lua_cocos2dx_ClippingNode_isInverted(lua_State* tolua_S) { if(!ok) return 0; - bool ret = cobj->isInverted(); + bool ret = cobj->hasContent(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.ClippingNode:isInverted",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.ClippingNode:hasContent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_isInverted'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_hasContent'.",&tolua_err); #endif return 0; @@ -44610,6 +44610,50 @@ int lua_cocos2dx_ClippingNode_setAlphaThreshold(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ClippingNode_isInverted(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ClippingNode* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_isInverted'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->isInverted(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.ClippingNode:isInverted",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_isInverted'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ClippingNode_create(lua_State* tolua_S) { int argc = 0; @@ -44667,12 +44711,13 @@ int lua_register_cocos2dx_ClippingNode(lua_State* tolua_S) tolua_cclass(tolua_S,"ClippingNode","cc.ClippingNode","cc.Node",nullptr); tolua_beginmodule(tolua_S,"ClippingNode"); - tolua_function(tolua_S,"isInverted",lua_cocos2dx_ClippingNode_isInverted); + tolua_function(tolua_S,"hasContent",lua_cocos2dx_ClippingNode_hasContent); tolua_function(tolua_S,"setInverted",lua_cocos2dx_ClippingNode_setInverted); tolua_function(tolua_S,"setStencil",lua_cocos2dx_ClippingNode_setStencil); tolua_function(tolua_S,"getAlphaThreshold",lua_cocos2dx_ClippingNode_getAlphaThreshold); tolua_function(tolua_S,"getStencil",lua_cocos2dx_ClippingNode_getStencil); tolua_function(tolua_S,"setAlphaThreshold",lua_cocos2dx_ClippingNode_setAlphaThreshold); + tolua_function(tolua_S,"isInverted",lua_cocos2dx_ClippingNode_isInverted); tolua_function(tolua_S,"create", lua_cocos2dx_ClippingNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ClippingNode).name(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index f266a640b9..f8080968eb 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1643,6 +1643,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ diff --git a/cocos/ui/CMakeLists.txt b/cocos/ui/CMakeLists.txt index 696a83295a..42f2cde9a8 100644 --- a/cocos/ui/CMakeLists.txt +++ b/cocos/ui/CMakeLists.txt @@ -1,5 +1,5 @@ -if(WINDOWS AND NOT BUILD_STATIC) +if(WINDOWS AND BUILD_SHARED_LIBS) ADD_DEFINITIONS (-D_USEGUIDLL) endif() diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp index 2c60aa56cc..b1faaae802 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp @@ -690,14 +690,16 @@ void EditBoxImplWin::openKeyboard() { _delegate->editBoxEditingDidBegin(_editBox); } - - EditBox* pEditBox = this->getEditBox(); - if (nullptr != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) + +#if CC_ENABLE_SCRIPT_BINDING + auto editBox = this->getEditBox(); + if (editBox && editBox->getScriptEditBoxHandler()) { - CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox); + CommonScriptData data(editBox->getScriptEditBoxHandler(), "began",editBox); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } +#endif std::string placeHolder = _labelPlaceHolder->getString(); if (placeHolder.length() == 0) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp index 0086e7eab0..d30bb3c5a5 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp @@ -330,7 +330,7 @@ void UIEditBoxImplWinrt::openKeyboard() { _delegate->editBoxEditingDidBegin(_editBox); } - +#if CC_ENABLE_SCRIPT_BINDING EditBox* pEditBox = this->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { @@ -338,7 +338,7 @@ void UIEditBoxImplWinrt::openKeyboard() ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } - +#endif std::string placeHolder = m_pLabelPlaceHolder->getString(); if (placeHolder.length() == 0) placeHolder = "Enter value"; diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-wp8.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-wp8.cpp index 892e53daf6..ceb918f2e0 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-wp8.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-wp8.cpp @@ -66,7 +66,7 @@ void UIEditBoxImplWp8::openKeyboard() { _delegate->editBoxEditingDidBegin(_editBox); } - +#if CC_ENABLE_SCRIPT_BINDING EditBox* pEditBox = this->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { @@ -74,7 +74,7 @@ void UIEditBoxImplWp8::openKeyboard() ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } - +#endif std::string placeHolder = m_pLabelPlaceHolder->getString(); if (placeHolder.length() == 0) placeHolder = "Enter value"; diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index fd212cba4e..17f7b95a95 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -1,20 +1,7 @@ -if(WINDOWS AND NOT BUILD_STATIC) +if(WINDOWS AND BUILD_SHARED_LIBS) ADD_DEFINITIONS (-D_USREXDLL) endif() -if(WINDOWS) - -# set(PLATFORM_EXTENSIONS_SRC -# ../extensions/proj.win32/Win32InputBox.cpp -# ) - -elseif(MACOSX) - -else() -# set(PLATFORM_EXTENSIONS_SRC -# ../../extensions/GUI/CCEditBox/CCEditBoxImplNone.cpp) -endif() - include_directories( ../../extensions ) diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index d3f57bb3e4..cfdc61fae1 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -41,7 +41,11 @@ #include "base/CCUserDefault.h" #include "platform/CCFileUtils.h" +#ifdef MINIZIP_FROM_SYSTEM +#include +#else // from our embedded sources #include "unzip.h" +#endif using namespace cocos2d; using namespace std; diff --git a/extensions/assets-manager/AssetsManagerEx.cpp b/extensions/assets-manager/AssetsManagerEx.cpp index c772f9eb14..95d46b029f 100644 --- a/extensions/assets-manager/AssetsManagerEx.cpp +++ b/extensions/assets-manager/AssetsManagerEx.cpp @@ -30,7 +30,11 @@ #include #include +#ifdef MINIZIP_FROM_SYSTEM +#include +#else // from our embedded sources #include "unzip.h" +#endif using namespace cocos2d; using namespace std; diff --git a/external/config.json b/external/config.json index a5c4c73a5e..4bf73adedd 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-21", + "version":"v3-deps-22", "zip_file_size":"87419231", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 873d75d685..cfc5a0d2c2 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -52,11 +52,26 @@ "cmake/BuildHelpers.CMakeLists.txt", "cmake/Modules/CMakeParseArguments.cmake", "cmake/Modules/CocosBuildHelpers.cmake", + "cmake/Modules/CocosUsePrebuiltLibs.cmake", + "cmake/Modules/FindCURL.cmake", "cmake/Modules/FindChipmunk.cmake", + "cmake/Modules/FindFMODEX.cmake", + "cmake/Modules/FindFontconfig.cmake", + "cmake/Modules/FindFreetype.cmake", "cmake/Modules/FindGLFW3.cmake", + "cmake/Modules/FindJPEG.cmake", + "cmake/Modules/FindMINIZIP.cmake", + "cmake/Modules/FindMPG123.cmake", + "cmake/Modules/FindOgg.cmake", + "cmake/Modules/FindPNG.cmake", "cmake/Modules/FindPackageHandleStandardArgs.cmake", "cmake/Modules/FindPackageMessage.cmake", + "cmake/Modules/FindTIFF.cmake", + "cmake/Modules/FindTinyXML2.cmake", + "cmake/Modules/FindVorbis.cmake", + "cmake/Modules/FindWEBSOCKETS.cmake", "cmake/Modules/FindWebP.cmake", + "cmake/Modules/SelectLibraryConfigurations.cmake", "cmake/android.toolchain.cmake", "cmake/ios.toolchain.cmake", "cocos/2d/CCAction.cpp", diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp index 943b0856fc..3f696abba7 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp @@ -48,51 +48,107 @@ void OpenGLES::Initialize() EGL_NONE }; - const EGLint displayAttributes[] = - { - // This can be used to configure D3D11. For example, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE could be used. - // This would ask the graphics card to use D3D11 Feature Level 9_3 instead of Feature Level 11_0+. - // On Windows Phone, this would allow the Phone Emulator to act more like the GPUs that are available on real Phone devices. -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE, - EGL_NONE, -#else - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_NONE, -#endif - }; - const EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; - // eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in 'displayAttributes' to configure D3D11. + const EGLint defaultDisplayAttributes[] = + { + // These are the default display attributes, used to request ANGLE's D3D11 renderer. + // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + + // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. + // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE, + }; + + const EGLint fl9_3DisplayAttributes[] = + { + // These can be used to request ANGLE's D3D11 renderer, with D3D11 Feature Level 9_3. + // These attributes are used if the call to eglInitialize fails with the default display attributes. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, + EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE, + }; + + const EGLint warpDisplayAttributes[] = + { + // These attributes can be used to request D3D11 WARP. + // They are used if eglInitialize fails with both the default display attributes and the 9_3 display attributes. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_USE_WARP_ANGLE, EGL_TRUE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE, + }; + + EGLConfig config = NULL; + + // eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in display attributes, used to configure D3D11. PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast(eglGetProcAddress("eglGetPlatformDisplayEXT")); if (!eglGetPlatformDisplayEXT) { throw Exception::CreateException(E_FAIL, L"Failed to get function eglGetPlatformDisplayEXT"); } - mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes); + // + // To initialize the display, we make three sets of calls to eglGetPlatformDisplayEXT and eglInitialize, with varying + // parameters passed to eglGetPlatformDisplayEXT: + // 1) The first calls uses "defaultDisplayAttributes" as a parameter. This corresponds to D3D11 Feature Level 10_0+. + // 2) If eglInitialize fails for step 1 (e.g. because 10_0+ isn't supported by the default GPU), then we try again + // using "fl9_3DisplayAttributes". This corresponds to D3D11 Feature Level 9_3. + // 3) If eglInitialize fails for step 2 (e.g. because 9_3+ isn't supported by the default GPU), then we try again + // using "warpDisplayAttributes". This corresponds to D3D11 Feature Level 11_0 on WARP, a D3D11 software rasterizer. + // + // Note: On Windows Phone, we #ifdef out the first set of calls to eglPlatformDisplayEXT and eglInitialize. + // Windows Phones devices only support D3D11 Feature Level 9_3, but the Windows Phone emulator supports 11_0+. + // We use this #ifdef to limit the Phone emulator to Feature Level 9_3, making it behave more like + // real Windows Phone devices. + // If you wish to test Feature Level 10_0+ in the Windows Phone emulator then you should remove this #ifdef. + // + +#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) + // This tries to initialize EGL to D3D11 Feature Level 10_0+. See above comment for details. + mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); if (mEglDisplay == EGL_NO_DISPLAY) { - throw Exception::CreateException(E_FAIL, L"Failed to get default EGL display"); + throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); } if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) +#endif { - throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); + // This tries to initialize EGL to D3D11 Feature Level 9_3, if 10_0+ is unavailable (e.g. on Windows Phone, or certain Windows tablets). + mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); + if (mEglDisplay == EGL_NO_DISPLAY) + { + throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); + } + + if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) + { + // This initializes EGL to D3D11 Feature Level 11_0 on WARP, if 9_3+ is unavailable on the default GPU (e.g. on Surface RT). + mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes); + if (mEglDisplay == EGL_NO_DISPLAY) + { + throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); + } + + if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) + { + // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. + throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); + } + } } EGLint numConfigs = 0; - if (eglGetConfigs(mEglDisplay, NULL, 0, &numConfigs) == EGL_FALSE) - { - throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count"); - } - - if (eglChooseConfig(mEglDisplay, configAttributes, &mEglConfig, 1, &numConfigs) == EGL_FALSE) + if ((eglChooseConfig(mEglDisplay, configAttributes, &mEglConfig, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0)) { throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig"); } @@ -134,6 +190,14 @@ EGLSurface OpenGLES::CreateSurface(SwapChainPanel^ panel, const Size* renderSurf EGLSurface surface = EGL_NO_SURFACE; + const EGLint surfaceAttributes[] = + { + // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). + // If you have compilation issues with it then please update your Visual Studio templates. + EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_NONE + }; + // Create a PropertySet and initialize with the EGLNativeWindowType. PropertySet^ surfaceCreationProperties = ref new PropertySet(); surfaceCreationProperties->Insert(ref new String(EGLNativeWindowTypeProperty), panel); @@ -144,7 +208,7 @@ EGLSurface OpenGLES::CreateSurface(SwapChainPanel^ panel, const Size* renderSurf surfaceCreationProperties->Insert(ref new String(EGLRenderSurfaceSizeProperty), PropertyValue::CreateSize(*renderSurfaceSize)); } - surface = eglCreateWindowSurface(mEglDisplay, mEglConfig, reinterpret_cast(surfaceCreationProperties), NULL); + surface = eglCreateWindowSurface(mEglDisplay, mEglConfig, reinterpret_cast(surfaceCreationProperties), surfaceAttributes); if (surface == EGL_NO_SURFACE) { throw Exception::CreateException(E_FAIL, L"Failed to create EGL surface"); diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h index ce9f2a9cdf..1a57b68739 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h @@ -28,7 +28,6 @@ #include #include - class OpenGLES { public: diff --git a/tests/cpp-empty-test/CMakeLists.txt b/tests/cpp-empty-test/CMakeLists.txt index 0fde5bb6bd..fa3f9ab5c9 100644 --- a/tests/cpp-empty-test/CMakeLists.txt +++ b/tests/cpp-empty-test/CMakeLists.txt @@ -1,15 +1,11 @@ set(APP_NAME cpp-empty-test) if(ANDROID) - set(PLATFORM_SRC - proj.android/jni/hellocpp/main.cpp - ) - + set(PLATFORM_SRC proj.android/jni/hellocpp/main.cpp) + set(RES_PREFIX "/Resources") elseif(WINDOWS) - set(PLATFORM_SRC - proj.win32/main.cpp - ) - + set(PLATFORM_SRC proj.win32/main.cpp) + set(RES_PREFIX "") elseif(IOS) set(PLATFORM_SRC proj.ios/main.m @@ -18,19 +14,15 @@ elseif(IOS) ) elseif(MACOSX OR APPLE) - set(PLATFORM_SRC - proj.mac/main.cpp - ) + set(PLATFORM_SRC proj.mac/main.cpp) file(GLOB_RECURSE RES_FILES Resources/*) cocos_mark_resources(FILES ${RES_FILES} BASEDIR Resources) list(APPEND PLATFORM_SRC ${RES_FILES}) elseif(LINUX) - set(PLATFORM_SRC - proj.linux/main.cpp - ) - + set(PLATFORM_SRC proj.linux/main.cpp) + set(RES_PREFIX "/Resources") else() message( FATAL_ERROR "Unsupported platform, CMake will exit" ) @@ -83,8 +75,7 @@ else() set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") add_custom_command(TARGET ${APP_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory $/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources $/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources $${RES_PREFIX} ) endif() diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index dac761970a..6dd51fdcd2 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -1,22 +1,18 @@ set(APP_NAME cpp-tests) if(WIN32) - set(PLATFORM_SRC - proj.win32/main.cpp - ) + set(PLATFORM_SRC proj.win32/main.cpp) + set(RES_PREFIX "") elseif(MACOSX) - set(PLATFORM_SRC - proj.mac/main.cpp - ) + set(PLATFORM_SRC proj.mac/main.cpp) file(GLOB_RECURSE RES_FILES Resources/*) cocos_mark_resources(FILES ${RES_FILES} BASEDIR Resources) list(APPEND PLATFORM_SRC ${RES_FILES}) elseif(LINUX) - set(PLATFORM_SRC - proj.linux/main.cpp - ) + set(PLATFORM_SRC proj.linux/main.cpp) + set(RES_PREFIX "/Resources") else() message( FATAL_ERROR "Unsupported platform, CMake will exit" ) endif() @@ -27,11 +23,6 @@ set(TESTS_SRC Classes/ActionsProgressTest/ActionsProgressTest.cpp Classes/ActionsTest/ActionsTest.cpp Classes/BillBoardTest/BillBoardTest.cpp - Classes/Box2DTest/Box2dTest.cpp - Classes/Box2DTestBed/Box2dView.cpp - Classes/Box2DTestBed/GLES-Render.cpp - Classes/Box2DTestBed/Test.cpp - Classes/Box2DTestBed/TestEntries.cpp Classes/BugsTest/Bug-1159.cpp Classes/BugsTest/Bug-1174.cpp Classes/BugsTest/Bug-350.cpp @@ -203,6 +194,20 @@ set(TESTS_SRC ${PLATFORM_SRC} ) +if(USE_CHIPMUNK) + include_directories(${CHIPMUNK_INCLUDE_DIRS}) +endif() + +if(USE_BOX2D) + list(APPEND TESTS_SRC + Classes/Box2DTest/Box2dTest.cpp + Classes/Box2DTestBed/Box2dView.cpp + Classes/Box2DTestBed/GLES-Render.cpp + Classes/Box2DTestBed/Test.cpp + Classes/Box2DTestBed/TestEntries.cpp + ) +endif() + if(LINUX) set(EXTENDED_TESTS_SRC ) @@ -229,7 +234,6 @@ endif() include_directories( Classes - ${CMAKE_SOURCE_DIR}/external/chipmunk/include/chipmunk ${CMAKE_SOURCE_DIR}/cocos/editor-support ) @@ -255,8 +259,7 @@ else() set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") pre_build(${APP_NAME} - COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}${RES_PREFIX} ) endif() diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index c6776c7797..4748f6d2ec 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -42,8 +42,10 @@ Controller g_aTestNames[] = { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) { "Audio - NewAudioEngine", []() { return new AudioEngineTestScene(); } }, #endif +#if CC_ENABLE_BOX2D_INTEGRATION { "Box2d - Basic", []() { return new Box2DTestScene(); } }, { "Box2d - TestBed", []() { return new Box2dTestBedScene(); } }, +#endif { "Bugs", []() { return new BugsTestScene(); } }, { "Chipmunk", []() { return new ChipmunkAccelTouchTestScene(); } }, { "Click and Move", [](){return new ClickAndMoveTestScene(); } }, diff --git a/tests/cpp-tests/Classes/tests.h b/tests/cpp-tests/Classes/tests.h index ce6f29c882..78db79616e 100644 --- a/tests/cpp-tests/Classes/tests.h +++ b/tests/cpp-tests/Classes/tests.h @@ -30,8 +30,10 @@ #include "SpriteTest/SpriteTest.h" #include "SchedulerTest/SchedulerTest.h" #include "RenderTextureTest/RenderTextureTest.h" +#if CC_ENABLE_BOX2D_INTEGRATION #include "Box2DTest/Box2dTest.h" #include "Box2DTestBed/Box2dView.h" +#endif #include "EffectsAdvancedTest/EffectsAdvancedTest.h" #include "InputTest/MouseTest.h" #include "PerformanceTest/PerformanceTest.h" diff --git a/tests/lua-empty-test/project/CMakeLists.txt b/tests/lua-empty-test/project/CMakeLists.txt index 362fe2df48..399d645dec 100644 --- a/tests/lua-empty-test/project/CMakeLists.txt +++ b/tests/lua-empty-test/project/CMakeLists.txt @@ -1,19 +1,15 @@ set(APP_NAME lua-empty-test) -set(SAMPLE_SRC - Classes/AppDelegate.cpp -) +set(SAMPLE_SRC Classes/AppDelegate.cpp) if(LINUX) - set(SAMPLE_SRC - ${SAMPLE_SRC} - proj.linux/main.cpp - ) + set(SAMPLE_SRC ${SAMPLE_SRC} proj.linux/main.cpp) + set(RES_PREFIX "/Resources") +elseif(WINDOWS) + list(APPEND SAMPLE_SRC proj.win32/main.cpp) + set(RES_PREFIX "") elseif(MACOSX OR APPLE) - set(SAMPLE_SRC - ${SAMPLE_SRC} - proj.mac/main.cpp - ) + set(SAMPLE_SRC ${SAMPLE_SRC} proj.mac/main.cpp) file(GLOB_RECURSE APP_RESOURCES ../res/*) cocos_mark_resources(FILES ${APP_RESOURCES} BASEDIR ../res RESOURCEBASE Resources/res) @@ -50,10 +46,9 @@ else() set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") pre_build(${APP_NAME} - COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}/Resources/res - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}/Resources/src - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ ${APP_BIN_DIR}/Resources/src/cocos + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}${RES_PREFIX}/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ ${APP_BIN_DIR}${RES_PREFIX}/src/cocos ) endif() diff --git a/tests/lua-tests/project/CMakeLists.txt b/tests/lua-tests/project/CMakeLists.txt index 96fb6b6b87..404e5d2ea9 100644 --- a/tests/lua-tests/project/CMakeLists.txt +++ b/tests/lua-tests/project/CMakeLists.txt @@ -7,15 +7,13 @@ set(SAMPLE_SRC ) if(LINUX) - set(SAMPLE_SRC - ${SAMPLE_SRC} - proj.linux/main.cpp - ) + set(SAMPLE_SRC ${SAMPLE_SRC} proj.linux/main.cpp) + set(RES_PREFIX "/Resources") +elseif(WINDOWS) + list(APPEND SAMPLE_SRC proj.win32/main.cpp) + set(RES_PREFIX "") elseif(MACOSX) - set(SAMPLE_SRC - ${SAMPLE_SRC} - proj.ios_mac/mac/main.cpp - ) + set(SAMPLE_SRC ${SAMPLE_SRC} proj.ios_mac/mac/main.cpp) file(GLOB_RECURSE APP_RESOURCES ../res/*) cocos_mark_resources(FILES ${APP_RESOURCES} BASEDIR ../res RESOURCEBASE Resources/res) @@ -55,11 +53,10 @@ else() set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") pre_build(${APP_NAME} - COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}/Resources/res - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}/Resources/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}${RES_PREFIX}/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/Resources/src COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ ${APP_BIN_DIR}/Resources/src/cocos - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests/cpp-tests/Resources ${APP_BIN_DIR}/Resources/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests/cpp-tests/Resources ${APP_BIN_DIR}${RES_PREFIX}/res ) endif() diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 40e5835664..aa82951329 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 40e583566474a9e1e0ed1c7ab7a746f4fa354fa0 +Subproject commit aa829513296354961e814078e646108e9cb92a2d diff --git a/tools/travis-scripts/config.gitingore b/tools/travis-scripts/config.gitingore index a0142c9bf8..46351496cb 100644 --- a/tools/travis-scripts/config.gitingore +++ b/tools/travis-scripts/config.gitingore @@ -115,6 +115,7 @@ tags !/cocos/2d/platform/android/java/res/ # Permit plugins to ship third-party libraries. !/plugin/plugins/*/proj.android/libs/*.jar +!/plugin/plugins/*/proj.android/libs v*-deps-*.zip v*-lua-runtime-*.zip diff --git a/tools/travis-scripts/generate-template-files.py b/tools/travis-scripts/generate-template-files.py index 6da3e33378..f629d71f68 100755 --- a/tools/travis-scripts/generate-template-files.py +++ b/tools/travis-scripts/generate-template-files.py @@ -97,6 +97,7 @@ class CocosFileList: self.fileList_lua.append("%s/" %relativePath) else: self.fileList_com.append("%s/" %relativePath) + self.__parseFileList(path) continue if ( self.__bExclude("/%s" %relativePath) or