diff --git a/CHANGELOG b/CHANGELOG
index 8cf7b01ae0..2f4916503f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,10 +4,18 @@ cocos2d-x-4.0 ??
[HIGHLIGHT] Use CMake for all platforms
[REFINE] Update glfw to 3.3
+[REFINE] Update minizip to 1.2
[CHANGE] remove deprecated functions
[CHANGE] remove h5 engine and JSB
[CHANGE] remove tiff
+[CHANGE] remove `experimental` namespace
+
+[FIX] system font can not work correctly on macOS 15
+[FIX] TextField can not work if using system input to get Chinese characters with iOS13
+[FIX] UIWebView uses WKWebView instead
+[FIX] VideoPlayer uses AVPlayerController instead
+[FX] lua crashes on 64it devcices
cocos2d-x-3.17 May.21 2018
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7deb315259..856d9843e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,13 @@ cmake_minimum_required(VERSION 3.6)
project(Cocos2d-x)
+# set default minimum deployment target
+if(XCODE)
+ if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
+ SET (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0)
+ endif()
+endif()
+
# cocos2dx root path
set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)
diff --git a/cmake/Modules/CocosBuildHelpers.cmake b/cmake/Modules/CocosBuildHelpers.cmake
index 38ece29037..f512262d65 100644
--- a/cmake/Modules/CocosBuildHelpers.cmake
+++ b/cmake/Modules/CocosBuildHelpers.cmake
@@ -202,6 +202,10 @@ function(setup_cocos_app_config app_name)
if(XCODE OR VS)
cocos_mark_code_files(${app_name})
endif()
+
+ if (XCODE)
+ cocos_config_app_xcode_property(${app_name})
+ endif()
endfunction()
# if cc_variable not set, then set it cc_value
@@ -211,52 +215,6 @@ macro(cocos_set_default_value cc_variable cc_value)
endif()
endmacro()
-# generate macOS app package infomations, need improve for example, the using of info.plist
-function(cocos_pak_xcode cocos_target)
- set(oneValueArgs
- INFO_PLIST
- BUNDLE_NAME
- BUNDLE_VERSION
- COPYRIGHT
- GUI_IDENTIFIER
- ICON_FILE
- INFO_STRING
- LONG_VERSION_STRING
- SHORT_VERSION_STRING
- )
- set(multiValueArgs)
- cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- string(TIMESTAMP ARGS_COPYRIGHT_YEAR "%Y")
- # set default value
- cocos_set_default_value(ARGS_INFO_PLIST "MacOSXBundleInfo.plist.in")
- cocos_set_default_value(ARGS_BUNDLE_NAME "\${PRODUCT_NAME}")
- cocos_set_default_value(ARGS_BUNDLE_VERSION "1")
- cocos_set_default_value(ARGS_COPYRIGHT "Copyright © ${ARGS_COPYRIGHT_YEAR}. All rights reserved.")
- cocos_set_default_value(ARGS_GUI_IDENTIFIER "org.cocos2dx.${APP_NAME}")
- cocos_set_default_value(ARGS_ICON_FILE "Icon")
- cocos_set_default_value(ARGS_INFO_STRING "cocos2d-x app")
- cocos_set_default_value(ARGS_LONG_VERSION_STRING "1.0.0")
- cocos_set_default_value(ARGS_SHORT_VERSION_STRING "1.0")
- # set default values for Info.plist template
- set_target_properties(${cocos_target}
- PROPERTIES
- MACOSX_BUNDLE_INFO_PLIST ${ARGS_INFO_PLIST}
- )
- set(MACOSX_BUNDLE_BUNDLE_NAME ${ARGS_BUNDLE_NAME} PARENT_SCOPE)
- set(MACOSX_BUNDLE_BUNDLE_VERSION ${ARGS_BUNDLE_VERSION} PARENT_SCOPE)
- set(MACOSX_BUNDLE_COPYRIGHT ${ARGS_COPYRIGHT} PARENT_SCOPE)
- set(MACOSX_BUNDLE_GUI_IDENTIFIER ${ARGS_GUI_IDENTIFIER} PARENT_SCOPE)
- set(MACOSX_BUNDLE_ICON_FILE ${ARGS_ICON_FILE} PARENT_SCOPE)
- set(MACOSX_BUNDLE_INFO_STRING ${ARGS_INFO_STRING} PARENT_SCOPE)
- set(MACOSX_BUNDLE_LONG_VERSION_STRING ${ARGS_LONG_VERSION_STRING} PARENT_SCOPE)
- set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${ARGS_SHORT_VERSION_STRING} PARENT_SCOPE)
-
- message(STATUS "cocos package: ${cocos_target}, plist file: ${ARGS_INFO_PLIST}")
-
- cocos_config_app_xcode_property(${cocos_target})
-endfunction()
-
# set Xcode property for application, include all depend target
macro(cocos_config_app_xcode_property cocos_app)
set(depend_libs)
@@ -271,7 +229,6 @@ endmacro()
# custom Xcode property for iOS target
macro(cocos_config_target_xcode_property cocos_target)
if(IOS)
- set_xcode_property(${cocos_target} IPHONEOS_DEPLOYMENT_TARGET "8.0")
set_xcode_property(${cocos_target} ENABLE_BITCODE "NO")
set_xcode_property(${cocos_target} ONLY_ACTIVE_ARCH "YES")
endif()
@@ -368,4 +325,3 @@ function(cocos_use_pkg target pkg)
endif()
endfunction()
-
diff --git a/cmake/Modules/CocosBuildSet.cmake b/cmake/Modules/CocosBuildSet.cmake
index 738127c270..0c063a4c71 100644
--- a/cmake/Modules/CocosBuildSet.cmake
+++ b/cmake/Modules/CocosBuildSet.cmake
@@ -22,8 +22,7 @@ message(STATUS "CMAKE_MODULE_PATH:" ${CMAKE_MODULE_PATH})
message(STATUS "PROJECT_BINARY_DIR:" ${PROJECT_BINARY_DIR})
message(STATUS "ENGINE_BINARY_PATH:" ${ENGINE_BINARY_PATH})
-# the default behavior of build module
-option(DEBUG_MODE "Debug or Release?" ON)
+
option(BUILD_LUA_LIBS "Build lua libraries" OFF)
# include helper functions
diff --git a/cmake/Modules/CocosConfigDefine.cmake b/cmake/Modules/CocosConfigDefine.cmake
index 54ae371fa8..12f1300aea 100644
--- a/cmake/Modules/CocosConfigDefine.cmake
+++ b/cmake/Modules/CocosConfigDefine.cmake
@@ -45,20 +45,6 @@ elseif(CMAKE_GENERATOR MATCHES Visual)
endif()
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
-if(CMAKE_CONFIGURATION_TYPES)
- set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Reset the configurations to what we need" FORCE)
- message(STATUS "CMAKE_CONFIGURATION_TYPES: ${CMAKE_CONFIGURATION_TYPES}")
-else()
- if(NOT CMAKE_BUILD_TYPE)
- if(DEBUG_MODE) # build mode, Debug is default value
- set(CMAKE_BUILD_TYPE Debug)
- else()
- set(CMAKE_BUILD_TYPE Release)
- endif()
- endif()
- message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
-endif()
-
# custom target property for lua/js link
define_property(TARGET
PROPERTY CC_JS_DEPEND
@@ -76,6 +62,7 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
# check visual studio version
if(WINDOWS)
diff --git a/cmake/Modules/CocosConfigDepend.cmake b/cmake/Modules/CocosConfigDepend.cmake
index 8d0969a3ba..8919459869 100644
--- a/cmake/Modules/CocosConfigDepend.cmake
+++ b/cmake/Modules/CocosConfigDepend.cmake
@@ -24,7 +24,6 @@ macro(cocos2dx_depend)
elseif(APPLE)
include_directories(/System/Library/Frameworks)
- find_library(ICONV_LIBRARY iconv)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(FOUNDATION_LIBRARY Foundation)
find_library(OPENAL_LIBRARY OpenAL)
@@ -36,7 +35,6 @@ macro(cocos2dx_depend)
${AUDIOTOOLBOX_LIBRARY}
${QUARTZCORE_LIBRARY}
${FOUNDATION_LIBRARY}
- ${ICONV_LIBRARY}
${GAMECONTROLLER_LIBRARY}
${METAL_LIBRARY}
)
@@ -49,6 +47,7 @@ macro(cocos2dx_depend)
find_library(APPLICATIONSERVICES_LIBRARY ApplicationServices)
find_library(IOKIT_LIBRARY IOKit)
find_library(APPKIT_LIBRARY AppKit)
+ find_library(ICONV_LIBRARY iconv)
list(APPEND PLATFORM_SPECIFIC_LIBS
${COCOA_LIBRARY}
${OPENGL_LIBRARY}
@@ -56,6 +55,7 @@ macro(cocos2dx_depend)
${IOKIT_LIBRARY}
${COCOS_APPLE_LIBS}
${APPKIT_LIBRARY}
+ ${ICONV_LIBRARY}
)
elseif(IOS)
# Locate system libraries on iOS
@@ -68,7 +68,6 @@ macro(cocos2dx_depend)
find_library(SECURITY_LIBRARY Security)
find_library(CORE_GRAPHICS_LIBRARY CoreGraphics)
find_library(AV_FOUNDATION_LIBRARY AVFoundation)
- find_library(Z_LIBRARY z)
find_library(WEBKIT_LIBRARY WebKit)
list(APPEND PLATFORM_SPECIFIC_LIBS
${UIKIT_LIBRARY}
@@ -80,9 +79,10 @@ macro(cocos2dx_depend)
${SECURITY_LIBRARY}
${CORE_GRAPHICS_LIBRARY}
${AV_FOUNDATION_LIBRARY}
- ${Z_LIBRARY}
${WEBKIT_LIBRARY}
${COCOS_APPLE_LIBS}
+ "/usr/lib/libz.dylib"
+ "/usr/lib/libiconv.dylib"
)
endif()
endif()
diff --git a/cmake/Modules/iOSBundleInfo.plist.in b/cmake/Modules/iOSBundleInfo.plist.in
deleted file mode 100644
index fa2a779a2d..0000000000
--- a/cmake/Modules/iOSBundleInfo.plist.in
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- en
- CFBundleExecutable
- ${MACOSX_BUNDLE_EXECUTABLE_NAME}
- CFBundleGetInfoString
- ${MACOSX_BUNDLE_INFO_STRING}
- CFBundleIconFile
- ${MACOSX_BUNDLE_ICON_FILE}
- CFBundleIdentifier
- ${MACOSX_BUNDLE_GUI_IDENTIFIER}
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleLongVersionString
- ${MACOSX_BUNDLE_LONG_VERSION_STRING}
- CFBundleName
- ${MACOSX_BUNDLE_BUNDLE_NAME}
- CFBundlePackageType
- APPL
- CFBundleShortVersionString
- ${MACOSX_BUNDLE_SHORT_VERSION_STRING}
- CFBundleSignature
- ????
- CFBundleVersion
- ${MACOSX_BUNDLE_BUNDLE_VERSION}
- CSResourcesFileMapped
-
- LSRequiresIPhoneOS
-
- UIStatusBarHidden
-
- UIRequiresFullScreen
-
- UILaunchStoryboardName
- LaunchScreen
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationLandscapeRight
- UIInterfaceOrientationLandscapeLeft
-
- NSHumanReadableCopyright
- ${MACOSX_BUNDLE_COPYRIGHT}
- CFBundleIconFiles
-
- ${MACOSX_BUNDLE_ICON_FILE}
-
-
-
diff --git a/cmake/README.md b/cmake/README.md
index ce9e6b785b..cfa80ffaf8 100644
--- a/cmake/README.md
+++ b/cmake/README.md
@@ -60,9 +60,52 @@ cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos
open Cocos2d-x.xcodeproj
```
-The parameter `-DCMAKE_OSX_SYSROOT=iphoneos` is optional, it generates a build for running on the iOS device. If you want to run in the simulator, please add `-DCMAKE_OSX_SYSROOT=iphonesimulator`, but remember you can't run a metal-support app in the simulator until Xcode 11 and MacOS 10.15.
+#### How do I customize the generated Xcode project?
+
+Xcode project settings that you want to affect both the app project and the Cocos2d-X library project should be passed on the command
+line when invoking `cmake`.
+
+Xcode project settings that you want to affect the app project only shoudl be put into the its `CMakeLists.txt` file.
+
+Any Xcode Build Setting can be changed by setting `CMAKE_XCODE_ATTRIBUTE_XXX` where `XXX` is the name found within the Xcode Build
+Settings page of the target. The following image shows the name of the iOS Deployment Target:
+
+![Find Xcode Build Setting](images/Xcode_Find_Setting_Name.png)
+
+Cocos also provides the function `set_xcode_property()` to make this easier to set from within a `CMakeLists.txt` file, where only
+the `XXX` part needed to be specified:
+
+```
+set_xcode_property(${APP_NAME} XXX "Value")
+```
+
+##### Deployment Target
+
+As explained above, pass this on the command line so both the app the Cocos2d-x are built using the same version:
+
+For iOS pass `-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=version`, where `version` is `9.0`, `10.0`, etc.
+
+For macOS pass `-DCMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET=version`, where `version` is `10.12`, `10.13`, etc.
+
+##### Code Signing Development Team
+
+This should be set in the app `CMakeLists.txt` file. You only need to set the "Development Team" as Xcode will automatically manage the
+other settings (certificate type, etc.). However the value you set is the 10-digit serial number following the development team name,
+which you can see in the top-right of the [Apple Developer Certificates](https://developer.apple.com/account/resources/certificates/list) page.
+
+Set it like this:
+```
+set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")
+```
+
+##### Bundle Identifier, Version numbers and Device Support
+
+All this information is held in the `Info.plist` file that is part of the app's source files and is therefore not generated by `cmake`. Therefore
+you can update these values from the `General` page of the Xcode target and the values will be preserved the next time you regenerate the project
+from `cmake`:
+
+![Xcode General Page](images/Xcode_General_Page.png)
-if you want to sign iOS app in CMake, you will need to fill development team ID into `set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")`, or select to sign in Xcode after project files generated.
### Android Studio
diff --git a/cmake/images/Xcode_Find_Setting_Name.png b/cmake/images/Xcode_Find_Setting_Name.png
new file mode 100644
index 0000000000..2ce8a61818
Binary files /dev/null and b/cmake/images/Xcode_Find_Setting_Name.png differ
diff --git a/cmake/images/Xcode_General_Page.png b/cmake/images/Xcode_General_Page.png
new file mode 100644
index 0000000000..fc1eea565b
Binary files /dev/null and b/cmake/images/Xcode_General_Page.png differ
diff --git a/cocos/2d/CCActionCatmullRom.cpp b/cocos/2d/CCActionCatmullRom.cpp
index 4f1eb6d131..9e7d9f5c35 100644
--- a/cocos/2d/CCActionCatmullRom.cpp
+++ b/cocos/2d/CCActionCatmullRom.cpp
@@ -269,8 +269,8 @@ void CardinalSplineTo::update(float time)
}
else
{
- p = time / _deltaT;
- lt = (time - _deltaT * (float)p) / _deltaT;
+ p = (ssize_t)(time / _deltaT);
+ lt = (time - _deltaT * p) / _deltaT;
}
// Interpolate
diff --git a/cocos/2d/CCActionGrid3D.cpp b/cocos/2d/CCActionGrid3D.cpp
index 4bf8960f88..5f69e581f8 100644
--- a/cocos/2d/CCActionGrid3D.cpp
+++ b/cocos/2d/CCActionGrid3D.cpp
@@ -71,10 +71,11 @@ void Waves3D::update(float time)
{
for (j = 0; j < _gridSize.height + 1; ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i ,j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
- setVertex(Vec2(i, j), v);
+ setVertex(pos, v);
}
}
}
@@ -347,7 +348,8 @@ void Lens3D::update(float /*time*/)
{
for (j = 0; j < _gridSize.height + 1; ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
Vec2 vect = _position - Vec2(v.x, v.y);
float r = vect.getLength();
@@ -371,7 +373,7 @@ void Lens3D::update(float /*time*/)
}
}
- setVertex(Vec2(i, j), v);
+ setVertex(pos, v);
}
}
@@ -439,7 +441,8 @@ void Ripple3D::update(float time)
{
for (j = 0; j < (_gridSize.height+1); ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
Vec2 vect = _position - Vec2(v.x,v.y);
float r = vect.getLength();
@@ -450,7 +453,7 @@ void Ripple3D::update(float time)
v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate);
}
- setVertex(Vec2(i, j), v);
+ setVertex(pos, v);
}
}
}
@@ -506,7 +509,8 @@ void Shaky3D::update(float /*time*/)
{
for (j = 0; j < (_gridSize.height+1); ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i ,j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
v.x += (rand() % (_randrange*2)) - _randrange;
v.y += (rand() % (_randrange*2)) - _randrange;
if (_shakeZ)
@@ -514,7 +518,7 @@ void Shaky3D::update(float /*time*/)
v.z += (rand() % (_randrange*2)) - _randrange;
}
- setVertex(Vec2(i, j), v);
+ setVertex(pos, v);
}
}
}
@@ -571,10 +575,11 @@ void Liquid::update(float time)
{
for (j = 1; j < _gridSize.height; ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
- setVertex(Vec2(i, j), v);
+ setVertex(pos, v);
}
}
}
@@ -633,7 +638,8 @@ void Waves::update(float time)
{
for (j = 0; j < _gridSize.height + 1; ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
if (_vertical)
{
@@ -645,7 +651,7 @@ void Waves::update(float time)
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
}
- setVertex(Vec2(i, j), v);
+ setVertex(pos, v);
}
}
}
@@ -709,7 +715,8 @@ void Twirl::update(float time)
{
for (j = 0; j < (_gridSize.height+1); ++j)
{
- Vec3 v = getOriginalVertex(Vec2(i ,j));
+ Vec2 pos((float)i, (float)j);
+ Vec3 v = getOriginalVertex(pos);
Vec2 avg(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
float r = avg.getLength();
@@ -724,7 +731,7 @@ void Twirl::update(float time)
v.x = c.x + d.x;
v.y = c.y + d.y;
- setVertex(Vec2(i ,j), v);
+ setVertex(pos, v);
}
}
}
diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp
index b862e1f6ed..8dd7612254 100644
--- a/cocos/2d/CCActionInterval.cpp
+++ b/cocos/2d/CCActionInterval.cpp
@@ -2095,7 +2095,7 @@ Blink* Blink::reverse() const
FadeIn* FadeIn::create(float d)
{
FadeIn* action = new (std::nothrow) FadeIn();
- if (action && action->initWithDuration(d,255.0f))
+ if (action && action->initWithDuration(d,255))
{
action->autorelease();
return action;
@@ -2132,7 +2132,7 @@ void FadeIn::startWithTarget(cocos2d::Node *target)
if (nullptr != _reverseAction)
this->_toOpacity = this->_reverseAction->_fromOpacity;
else
- _toOpacity = 255.0f;
+ _toOpacity = 255;
if (target)
_fromOpacity = target->getOpacity();
@@ -2145,7 +2145,7 @@ void FadeIn::startWithTarget(cocos2d::Node *target)
FadeOut* FadeOut::create(float d)
{
FadeOut* action = new (std::nothrow) FadeOut();
- if (action && action->initWithDuration(d,0.0f))
+ if (action && action->initWithDuration(d,0))
{
action->autorelease();
return action;
@@ -2168,7 +2168,7 @@ void FadeOut::startWithTarget(cocos2d::Node *target)
if (nullptr != _reverseAction)
_toOpacity = _reverseAction->_fromOpacity;
else
- _toOpacity = 0.0f;
+ _toOpacity = 0;
if (target)
_fromOpacity = target->getOpacity();
diff --git a/cocos/2d/CCActionPageTurn3D.cpp b/cocos/2d/CCActionPageTurn3D.cpp
index 2d5630de1b..b5f149c680 100644
--- a/cocos/2d/CCActionPageTurn3D.cpp
+++ b/cocos/2d/CCActionPageTurn3D.cpp
@@ -74,7 +74,7 @@ void PageTurn3D::update(float time)
float deltaTheta = sqrtf(time);
float theta = deltaTheta > 0.5f ? (float)M_PI_2*deltaTheta : (float)M_PI_2*(1-deltaTheta);
- float rotateByYAxis = (2-time)* M_PI;
+ float rotateByYAxis = (2-time)* (float)M_PI;
float sinTheta = sinf(theta);
float cosTheta = cosf(theta);
@@ -83,8 +83,9 @@ void PageTurn3D::update(float time)
{
for (int j = 0; j <= _gridSize.height; ++j)
{
+ Vec2 pos((float)i, (float)j);
// Get original vertex
- Vec3 p = getOriginalVertex(Vec2(i ,j));
+ Vec3 p = getOriginalVertex(pos);
p.x -= getGridRect().origin.x;
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
@@ -124,7 +125,7 @@ void PageTurn3D::update(float time)
// Set new coords
p.x += getGridRect().origin.x;
- setVertex(Vec2(i, j), p);
+ setVertex(pos, p);
}
}
diff --git a/cocos/2d/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp
index b24ccd1134..3e624729f2 100644
--- a/cocos/2d/CCActionTiledGrid.cpp
+++ b/cocos/2d/CCActionTiledGrid.cpp
@@ -82,7 +82,8 @@ void ShakyTiles3D::update(float /*time*/)
{
for (j = 0; j < _gridSize.height; ++j)
{
- Quad3 coords = getOriginalTile(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Quad3 coords = getOriginalTile(pos);
// X
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
@@ -104,7 +105,7 @@ void ShakyTiles3D::update(float /*time*/)
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
}
- setTile(Vec2(i, j), coords);
+ setTile(pos, coords);
}
}
}
@@ -155,7 +156,8 @@ void ShatteredTiles3D::update(float /*time*/)
{
for (j = 0; j < _gridSize.height; ++j)
{
- Quad3 coords = getOriginalTile(Vec2(i ,j));
+ Vec2 pos((float)i, (float)j);
+ Quad3 coords = getOriginalTile(pos);
// X
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
@@ -177,7 +179,7 @@ void ShatteredTiles3D::update(float /*time*/)
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
}
- setTile(Vec2(i, j), coords);
+ setTile(pos, coords);
}
}
@@ -240,10 +242,8 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len)
Size ShuffleTiles::getDelta(const Size& pos) const
{
+ unsigned int idx = static_cast(pos.width * _gridSize.height + pos.height);
Vec2 pos2;
-
- unsigned int idx = pos.width * _gridSize.height + pos.height;
-
pos2.x = (float)(_tilesOrder[idx] / (int)_gridSize.height);
pos2.y = (float)(_tilesOrder[idx] % (int)_gridSize.height);
@@ -279,7 +279,7 @@ void ShuffleTiles::startWithTarget(Node *target)
std::srand(_seed);
}
- _tilesCount = _gridSize.width * _gridSize.height;
+ _tilesCount = (unsigned int)(_gridSize.width * _gridSize.height);
_tilesOrder = new unsigned int[_tilesCount];
/**
@@ -302,7 +302,7 @@ void ShuffleTiles::startWithTarget(Node *target)
{
tileArray->position.set((float)i, (float)j);
tileArray->startPosition.set((float)i, (float)j);
- tileArray->delta = getDelta(Size(i, j));
+ tileArray->delta = getDelta(Size((float)i, (float)j));
++tileArray;
}
}
@@ -317,7 +317,7 @@ void ShuffleTiles::update(float time)
for (int j = 0; j < _gridSize.height; ++j)
{
tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
- placeTile(Vec2(i, j), tileArray);
+ placeTile(Vec2((float)i, (float)j), tileArray);
++tileArray;
}
}
@@ -394,18 +394,19 @@ void FadeOutTRTiles::update(float time)
{
for (int j = 0; j < _gridSize.height; ++j)
{
- float distance = testFunc(Size(i, j), time);
+ Vec2 pos((float)i, (float)j);
+ float distance = testFunc(Size((float)i, (float)j), time);
if ( distance == 0 )
{
- turnOffTile(Vec2(i, j));
+ turnOffTile(pos);
} else
if (distance < 1)
{
- transformTile(Vec2(i, j), distance);
+ transformTile(pos, distance);
}
else
{
- turnOnTile(Vec2(i, j));
+ turnOnTile(pos);
}
}
}
@@ -604,7 +605,7 @@ void TurnOffTiles::startWithTarget(Node *target)
std::srand(_seed);
}
- _tilesCount = _gridSize.width * _gridSize.height;
+ _tilesCount = (unsigned int)(_gridSize.width * _gridSize.height);
_tilesOrder = new unsigned int[_tilesCount];
for (unsigned int i = 0; i < _tilesCount; ++i)
@@ -623,7 +624,9 @@ void TurnOffTiles::update(float time)
for (unsigned int i = 0; i < _tilesCount; i++ )
{
t = _tilesOrder[i];
- Vec2 tilePos( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
+ //needs integer value
+ unsigned int x = (unsigned int)(t / _gridSize.height);
+ Vec2 tilePos((float)x, (float)(t % (unsigned int)_gridSize.height));
if ( i < l )
{
@@ -678,7 +681,8 @@ void WavesTiles3D::update(float time)
{
for (int j = 0; j < _gridSize.height; j++ )
{
- Quad3 coords = getOriginalTile(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Quad3 coords = getOriginalTile(pos);
coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 +
(coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
@@ -686,7 +690,7 @@ void WavesTiles3D::update(float time)
coords.tl.z = coords.bl.z;
coords.tr.z = coords.bl.z;
- setTile(Vec2(i, j), coords);
+ setTile(pos, coords);
}
}
}
@@ -736,7 +740,8 @@ void JumpTiles3D::update(float time)
{
for (int j = 0; j < _gridSize.height; j++ )
{
- Quad3 coords = getOriginalTile(Vec2(i, j));
+ Vec2 pos((float)i, (float)j);
+ Quad3 coords = getOriginalTile(pos);
if ( ((i+j) % 2) == 0 )
{
@@ -753,7 +758,7 @@ void JumpTiles3D::update(float time)
coords.tr.z += sinz2;
}
- setTile(Vec2(i, j), coords);
+ setTile(pos, coords);
}
}
}
@@ -778,7 +783,7 @@ bool SplitRows::initWithDuration(float duration, unsigned int rows)
{
_rows = rows;
- return TiledGrid3DAction::initWithDuration(duration, Size(1, rows));
+ return TiledGrid3DAction::initWithDuration(duration, Size(1.0f, (float)rows));
}
SplitRows* SplitRows::clone() const
@@ -795,9 +800,10 @@ void SplitRows::startWithTarget(Node *target)
void SplitRows::update(float time)
{
- for (unsigned int j = 0; j < _gridSize.height; ++j)
+ for (int j = 0; j < _gridSize.height; ++j)
{
- Quad3 coords = getOriginalTile(Vec2(0, j));
+ Vec2 pos(0, (float)j);
+ Quad3 coords = getOriginalTile(pos);
float direction = 1;
if ( (j % 2 ) == 0 )
@@ -810,7 +816,7 @@ void SplitRows::update(float time)
coords.tl.x += direction * _winSize.width * time;
coords.tr.x += direction * _winSize.width * time;
- setTile(Vec2(0, j), coords);
+ setTile(pos, coords);
}
}
@@ -833,7 +839,7 @@ SplitCols* SplitCols::create(float duration, unsigned int cols)
bool SplitCols::initWithDuration(float duration, unsigned int cols)
{
_cols = cols;
- return TiledGrid3DAction::initWithDuration(duration, Size(cols, 1));
+ return TiledGrid3DAction::initWithDuration(duration, Size((float)cols, 1.0f));
}
SplitCols* SplitCols::clone() const
@@ -852,7 +858,8 @@ void SplitCols::update(float time)
{
for (unsigned int i = 0; i < _gridSize.width; ++i)
{
- Quad3 coords = getOriginalTile(Vec2(i, 0));
+ Vec2 pos((float)i, 0);
+ Quad3 coords = getOriginalTile(pos);
float direction = 1;
if ( (i % 2 ) == 0 )
@@ -865,7 +872,7 @@ void SplitCols::update(float time)
coords.tl.y += direction * _winSize.height * time;
coords.tr.y += direction * _winSize.height * time;
- setTile(Vec2(i, 0), coords);
+ setTile(pos, coords);
}
}
diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp
index 6eea8166d8..91183550d3 100644
--- a/cocos/2d/CCAtlasNode.cpp
+++ b/cocos/2d/CCAtlasNode.cpp
@@ -25,8 +25,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
#include "2d/CCAtlasNode.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "renderer/CCTextureAtlas.h"
#include "base/CCDirector.h"
#include "renderer/CCTextureCache.h"
@@ -44,7 +45,8 @@ NS_CC_BEGIN
AtlasNode::AtlasNode()
{
auto& pipelineDescriptor = _quadCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
_mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
diff --git a/cocos/2d/CCAutoPolygon.cpp b/cocos/2d/CCAutoPolygon.cpp
index f2cff63a92..e35b62a749 100644
--- a/cocos/2d/CCAutoPolygon.cpp
+++ b/cocos/2d/CCAutoPolygon.cpp
@@ -166,7 +166,7 @@ float PolygonInfo::getArea() const
float area = 0;
V3F_C4B_T2F *verts = triangles.verts;
unsigned short *indices = triangles.indices;
- for(int i = 0; i < triangles.indexCount; i+=3)
+ for(unsigned int i = 0; i < triangles.indexCount; i+=3)
{
auto A = verts[indices[i]].vertices;
auto B = verts[indices[i+1]].vertices;
@@ -249,13 +249,13 @@ unsigned int AutoPolygon::getSquareValue(unsigned int x, unsigned int y, const R
//NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel
auto fixedRect = Rect(rect.origin, rect.size-Size(2,2));
- Vec2 tl = Vec2(x-1, y-1);
+ Vec2 tl = Vec2(x-1.0f, y-1.0f);
sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0;
- Vec2 tr = Vec2(x, y-1);
+ Vec2 tr = Vec2(x-0.0f, y-1.0f);
sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold)? 2 : 0;
- Vec2 bl = Vec2(x-1, y);
+ Vec2 bl = Vec2(x-1.0f, y-0.0f);
sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold)? 4 : 0;
- Vec2 br = Vec2(x, y);
+ Vec2 br = Vec2(x-0.0f, y-0.0f);
sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold)? 8 : 0;
CCASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15");
return sv;
@@ -267,8 +267,8 @@ std::vector AutoPolygon::marchSquare(const Rect& rect, const Vec2
int stepy = 0;
int prevx = 0;
int prevy = 0;
- int startx = start.x;
- int starty = start.y;
+ int startx = (int)start.x;
+ int starty = (int)start.y;
int curx = startx;
int cury = starty;
unsigned int count = 0;
@@ -526,7 +526,7 @@ std::vector AutoPolygon::expand(const std::vector& points, const coc
ClipperLib::PolyTree out;
for(const auto& pt : points)
{
- subj << ClipperLib::IntPoint(pt.x* PRECISION, pt.y * PRECISION);
+ subj << ClipperLib::IntPoint(static_cast(pt.x* PRECISION), static_cast(pt.y * PRECISION));
}
ClipperLib::ClipperOffset co;
co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon);
@@ -551,9 +551,10 @@ std::vector AutoPolygon::expand(const std::vector& points, const coc
//create the clipping rect
ClipperLib::Path clamp;
clamp.push_back(ClipperLib::IntPoint(0, 0));
- clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, 0));
- clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, rect.size.height/_scaleFactor * PRECISION));
- clamp.push_back(ClipperLib::IntPoint(0, rect.size.height/_scaleFactor * PRECISION));
+ clamp.push_back(ClipperLib::IntPoint(static_cast(rect.size.width/_scaleFactor * PRECISION), 0));
+ clamp.push_back(ClipperLib::IntPoint(static_cast(rect.size.width/_scaleFactor * PRECISION),
+ static_cast(rect.size.height/_scaleFactor * PRECISION)));
+ clamp.push_back(ClipperLib::IntPoint(0, static_cast(rect.size.height/_scaleFactor * PRECISION)));
cl.AddPath(clamp, ClipperLib::ptClip, true);
cl.Execute(ClipperLib::ctIntersection, out);
@@ -599,10 +600,10 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& po
for(int i = 0; i < 3; ++i)
{
auto p = ite->GetPoint(i);
- auto v3 = Vec3(p->x, p->y, 0);
+ auto v3 = Vec3((float)p->x, (float)p->y, 0);
bool found = false;
- size_t j;
- size_t length = vdx;
+ unsigned short j;
+ auto length = vdx;
for(j = 0; j < length; j++)
{
if(verts[j].vertices == v3)
@@ -668,8 +669,8 @@ void AutoPolygon::calculateUV(const Rect& rect, V3F_C4B_T2F* verts, ssize_t coun
*/
CCASSERT(_width && _height, "please specify width and height for this AutoPolygon instance");
- float texWidth = _width;
- float texHeight = _height;
+ auto texWidth = _width;
+ auto texHeight = _height;
auto end = &verts[count];
for(auto i = verts; i != end; ++i)
@@ -690,7 +691,7 @@ Rect AutoPolygon::getRealRect(const Rect& rect)
{
//if the instance doesn't have width and height, then the whole operation is kaput
CCASSERT(_height && _width, "Please specify a width and height for this instance before using its functions");
- realRect = Rect(0,0, _width, _height);
+ realRect = Rect(0,0, (float)_width, (float)_height);
}
else{
//rect is specified, so convert to real rect
diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp
index f21282d21f..defd7332ec 100644
--- a/cocos/2d/CCCamera.cpp
+++ b/cocos/2d/CCCamera.cpp
@@ -45,7 +45,7 @@ Camera* Camera::create()
Camera* camera = new (std::nothrow) Camera();
camera->initDefault();
camera->autorelease();
- camera->setDepth(0.f);
+ camera->setDepth(0);
return camera;
}
diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp
index f38c4f5d6d..01ad20741f 100644
--- a/cocos/2d/CCCameraBackgroundBrush.cpp
+++ b/cocos/2d/CCCameraBackgroundBrush.cpp
@@ -24,6 +24,8 @@
****************************************************************************/
#include "2d/CCCameraBackgroundBrush.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCCamera.h"
#include "base/ccMacros.h"
#include "base/ccUtils.h"
@@ -122,7 +124,8 @@ CameraBackgroundDepthBrush* CameraBackgroundDepthBrush::create(float depth)
bool CameraBackgroundDepthBrush::init()
{
CC_SAFE_RELEASE_NULL(_programState);
- _programState = new backend::ProgramState(cameraClear_vert, cameraClear_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::CAMERA_CLEAR);
+ _programState = new backend::ProgramState(program);
_locDepth = _programState->getUniformLocation("dpeth");
@@ -409,7 +412,8 @@ bool CameraBackgroundSkyBoxBrush::init()
_customCommand.setAfterCallback(CC_CALLBACK_0(CameraBackgroundSkyBoxBrush::onAfterDraw, this));
CC_SAFE_RELEASE_NULL(_programState);
- _programState = new backend::ProgramState(CC3D_skybox_vert, CC3D_skybox_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKYBOX_3D);
+ _programState = new backend::ProgramState(program);
_uniformColorLoc = _programState->getUniformLocation("u_color");
_uniformCameraRotLoc = _programState->getUniformLocation("u_cameraRot");
_uniformEnvLoc = _programState->getUniformLocation("u_Env");
diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp
index 0917331c71..9b99db4606 100644
--- a/cocos/2d/CCClippingNode.cpp
+++ b/cocos/2d/CCClippingNode.cpp
@@ -198,7 +198,8 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
auto alphaThreshold = this->getAlphaThreshold();
if (alphaThreshold < 1)
{
- auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColorAlphaTest_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST);
+ auto programState = new (std::nothrow) backend::ProgramState(program);
auto alphaLocation = programState->getUniformLocation("u_alpha_value");
programState->setUniform(alphaLocation, &alphaThreshold, sizeof(alphaThreshold));
setProgramStateRecursively(_stencil, programState);
diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp
index 97506debc3..cfdb282b68 100644
--- a/cocos/2d/CCDrawNode.cpp
+++ b/cocos/2d/CCDrawNode.cpp
@@ -23,6 +23,8 @@
*/
#include "2d/CCDrawNode.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "base/CCEventType.h"
#include "base/CCConfiguration.h"
#include "renderer/CCRenderer.h"
@@ -30,7 +32,6 @@
#include "base/CCEventListenerCustom.h"
#include "base/CCEventDispatcher.h"
#include "2d/CCActionCatmullRom.h"
-#include "platform/CCGL.h"
#include "base/ccUtils.h"
#include "renderer/ccShaders.h"
#include "renderer/backend/ProgramState.h"
@@ -149,21 +150,24 @@ bool DrawNode::init()
void DrawNode::updateShader()
{
CC_SAFE_RELEASE(_programState);
- _programState = new (std::nothrow) backend::ProgramState(positionColorLengthTexture_vert, positionColorLengthTexture_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_LENGTH_TEXTURE);
+ _programState = new (std::nothrow) backend::ProgramState(program);
_customCommand.getPipelineDescriptor().programState = _programState;
setVertexLayout(_customCommand);
_customCommand.setDrawType(CustomCommand::DrawType::ARRAY);
_customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE);
CC_SAFE_RELEASE(_programStatePoint);
- _programStatePoint = new (std::nothrow) backend::ProgramState(positionColorTextureAsPointsize_vert, positionColor_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_TEXTURE_AS_POINTSIZE);
+ _programStatePoint = new (std::nothrow) backend::ProgramState(program);
_customCommandGLPoint.getPipelineDescriptor().programState = _programStatePoint;
setVertexLayout(_customCommandGLPoint);
_customCommandGLPoint.setDrawType(CustomCommand::DrawType::ARRAY);
_customCommandGLPoint.setPrimitiveType(CustomCommand::PrimitiveType::POINT);
CC_SAFE_RELEASE(_programStateLine);
- _programStateLine = new (std::nothrow) backend::ProgramState(positionColorLengthTexture_vert, positionColorLengthTexture_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR_LENGTH_TEXTURE);
+ _programStateLine = new (std::nothrow) backend::ProgramState(program);
_customCommandGLLine.getPipelineDescriptor().programState = _programStateLine;
setVertexLayout(_customCommandGLLine);
_customCommandGLLine.setDrawType(CustomCommand::DrawType::ARRAY);
@@ -225,7 +229,7 @@ void DrawNode::updateUniforms(const Mat4 &transform, CustomCommand& cmd)
auto mvpLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
pipelineDescriptor.programState->setUniform(mvpLocation, matrixMVP.m, sizeof(matrixMVP.m));
- float alpha = _displayedOpacity / 255.0;
+ float alpha = _displayedOpacity / 255.0f;
auto alphaUniformLocation = pipelineDescriptor.programState->getUniformLocation("u_alpha");
pipelineDescriptor.programState->setUniform(alphaUniformLocation, &alpha, sizeof(alpha));
}
@@ -444,7 +448,7 @@ void DrawNode::drawCardinalSpline(PointArray *config, float tension, unsigned i
p = config->count() - 1;
lt = 1;
} else {
- p = dt / deltaT;
+ p = static_cast(dt / deltaT);
lt = (dt - deltaT * (float)p) / deltaT;
}
diff --git a/cocos/2d/CCFastTMXLayer.cpp b/cocos/2d/CCFastTMXLayer.cpp
index 7841b2c6ac..a11c0cd1ec 100644
--- a/cocos/2d/CCFastTMXLayer.cpp
+++ b/cocos/2d/CCFastTMXLayer.cpp
@@ -36,6 +36,8 @@ THE SOFTWARE.
*/
#include "2d/CCFastTMXLayer.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCFastTMXTiledMap.h"
#include "2d/CCSprite.h"
#include "2d/CCCamera.h"
@@ -49,16 +51,15 @@ THE SOFTWARE.
#include "renderer/backend/ProgramState.h"
NS_CC_BEGIN
-namespace experimental {
-const int TMXLayer::FAST_TMX_ORIENTATION_ORTHO = 0;
-const int TMXLayer::FAST_TMX_ORIENTATION_HEX = 1;
-const int TMXLayer::FAST_TMX_ORIENTATION_ISO = 2;
+const int FastTMXLayer::FAST_TMX_ORIENTATION_ORTHO = 0;
+const int FastTMXLayer::FAST_TMX_ORIENTATION_HEX = 1;
+const int FastTMXLayer::FAST_TMX_ORIENTATION_ISO = 2;
// FastTMXLayer - init & alloc & dealloc
-TMXLayer * TMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
+FastTMXLayer * FastTMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
- TMXLayer *ret = new (std::nothrow) TMXLayer();
+ FastTMXLayer *ret = new (std::nothrow) FastTMXLayer();
if (ret->initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo))
{
ret->autorelease();
@@ -68,7 +69,7 @@ TMXLayer * TMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo
return nullptr;
}
-bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
+bool FastTMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
if( tilesetInfo )
@@ -107,11 +108,11 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la
return true;
}
-TMXLayer::TMXLayer()
+FastTMXLayer::FastTMXLayer()
{
}
-TMXLayer::~TMXLayer()
+FastTMXLayer::~FastTMXLayer()
{
CC_SAFE_RELEASE(_tileSet);
CC_SAFE_RELEASE(_texture);
@@ -126,7 +127,7 @@ TMXLayer::~TMXLayer()
}
}
-void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
+void FastTMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
{
updateTotalQuads();
@@ -170,7 +171,7 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
}
}
-void TMXLayer::updateTiles(const Rect& culledRect)
+void FastTMXLayer::updateTiles(const Rect& culledRect)
{
Rect visibleTiles = Rect(culledRect.origin, culledRect.size * Director::getInstance()->getContentScaleFactor());
Size mapTileSize = CC_SIZE_PIXELS_TO_POINTS(_mapTileSize);
@@ -194,8 +195,8 @@ void TMXLayer::updateTiles(const Rect& culledRect)
float tileSizeMax = std::max(tileSize.width, tileSize.height);
if (_layerOrientation == FAST_TMX_ORIENTATION_ORTHO)
{
- tilesOverX = ceil(tileSizeMax / mapTileSize.width) - 1;
- tilesOverY = ceil(tileSizeMax / mapTileSize.height) - 1;
+ tilesOverX = (int)ceil(tileSizeMax / mapTileSize.width) - 1;
+ tilesOverY = (int)ceil(tileSizeMax / mapTileSize.height) - 1;
if (tilesOverX < 0) tilesOverX = 0;
if (tilesOverY < 0) tilesOverY = 0;
@@ -207,8 +208,8 @@ void TMXLayer::updateTiles(const Rect& culledRect)
if (overTileRect.size.height < 0) overTileRect.size.height = 0;
overTileRect = RectApplyTransform(overTileRect, nodeToTileTransform);
- tilesOverX = ceil(overTileRect.origin.x + overTileRect.size.width) - floor(overTileRect.origin.x);
- tilesOverY = ceil(overTileRect.origin.y + overTileRect.size.height) - floor(overTileRect.origin.y);
+ tilesOverX = (int)(ceil(overTileRect.origin.x + overTileRect.size.width) - floor(overTileRect.origin.x));
+ tilesOverY = (int)(ceil(overTileRect.origin.y + overTileRect.size.height) - floor(overTileRect.origin.y));
}
else
{
@@ -223,10 +224,10 @@ void TMXLayer::updateTiles(const Rect& culledRect)
_indicesVertexZNumber[iter.first] = iter.second;
}
- int yBegin = std::max(0.f,visibleTiles.origin.y - tilesOverY);
- int yEnd = std::min(_layerSize.height,visibleTiles.origin.y + visibleTiles.size.height + tilesOverY);
- int xBegin = std::max(0.f,visibleTiles.origin.x - tilesOverX);
- int xEnd = std::min(_layerSize.width,visibleTiles.origin.x + visibleTiles.size.width + tilesOverX);
+ int yBegin = static_cast(std::max(0.f,visibleTiles.origin.y - tilesOverY));
+ int yEnd = static_cast(std::min(_layerSize.height,visibleTiles.origin.y + visibleTiles.size.height + tilesOverY));
+ int xBegin = static_cast(std::max(0.f,visibleTiles.origin.x - tilesOverX));
+ int xEnd = static_cast(std::min(_layerSize.width,visibleTiles.origin.x + visibleTiles.size.width + tilesOverX));
for (int y = yBegin; y < yEnd; ++y)
{
@@ -235,13 +236,12 @@ void TMXLayer::updateTiles(const Rect& culledRect)
int tileIndex = getTileIndexByPos(x, y);
if(_tiles[tileIndex] == 0) continue;
- int vertexZ = getVertexZForPos(Vec2(x,y));
+ int vertexZ = getVertexZForPos(Vec2((float)x,(float)y));
auto iter = _indicesVertexZNumber.find(vertexZ);
int offset = iter->second;
iter->second++;
- int quadIndex = _tileToQuadIndex[tileIndex];
- CC_ASSERT(-1 != quadIndex);
+ unsigned short quadIndex = static_cast(_tileToQuadIndex[tileIndex]);
_indices[6 * offset + 0] = quadIndex * 4 + 0;
_indices[6 * offset + 1] = quadIndex * 4 + 1;
_indices[6 * offset + 2] = quadIndex * 4 + 2;
@@ -263,7 +263,7 @@ void TMXLayer::updateTiles(const Rect& culledRect)
}
-void TMXLayer::updateVertexBuffer()
+void FastTMXLayer::updateVertexBuffer()
{
unsigned int vertexBufferSize = (unsigned int)(sizeof(V3F_C4B_T2F) * _totalQuads.size() * 4);
if (!_vertexBuffer)
@@ -274,7 +274,7 @@ void TMXLayer::updateVertexBuffer()
_vertexBuffer->updateData(&_totalQuads[0], vertexBufferSize);
}
-void TMXLayer::updateIndexBuffer()
+void FastTMXLayer::updateIndexBuffer()
{
#ifdef CC_FAST_TILEMAP_32_BIT_INDICES
unsigned int indexBufferSize = (unsigned int)(sizeof(unsigned int) * _indices.size());
@@ -290,7 +290,7 @@ void TMXLayer::updateIndexBuffer()
}
// FastTMXLayer - setup Tiles
-void TMXLayer::setupTiles()
+void FastTMXLayer::setupTiles()
{
// Optimization: quick hack that sets the image size on the tileset
_tileSet->_imageSize = _texture->getContentSizeInPixels();
@@ -326,11 +326,11 @@ void TMXLayer::setupTiles()
break;
}
- _screenTileCount = _screenGridSize.width * _screenGridSize.height;
+ _screenTileCount = (int)(_screenGridSize.width * _screenGridSize.height);
}
-Mat4 TMXLayer::tileToNodeTransform()
+Mat4 FastTMXLayer::tileToNodeTransform()
{
float w = _mapTileSize.width / CC_CONTENT_SCALE_FACTOR();
float h = _mapTileSize.height / CC_CONTENT_SCALE_FACTOR();
@@ -382,7 +382,7 @@ Mat4 TMXLayer::tileToNodeTransform()
}
-void TMXLayer::updatePrimitives()
+void FastTMXLayer::updatePrimitives()
{
auto blendfunc = _texture->hasPremultipliedAlpha() ? BlendFunc::ALPHA_PREMULTIPLIED : BlendFunc::ALPHA_NON_PREMULTIPLIED;
for(const auto& iter : _indicesVertexZNumber)
@@ -408,16 +408,17 @@ void TMXLayer::updatePrimitives()
if (_useAutomaticVertexZ)
{
CC_SAFE_RELEASE(pipelineDescriptor.programState);
- auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColorAlphaTest_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST);
+ auto programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = programState;
_alphaValueLocation = pipelineDescriptor.programState->getUniformLocation("u_alpha_value");
pipelineDescriptor.programState->setUniform(_alphaValueLocation, &_alphaFuncValue, sizeof(_alphaFuncValue));
-
}
else
{
CC_SAFE_RELEASE(pipelineDescriptor.programState);
- auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ auto programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = programState;
}
auto vertexLayout = pipelineDescriptor.programState->getVertexLayout();
@@ -452,14 +453,14 @@ void TMXLayer::updatePrimitives()
}
}
-void TMXLayer::setOpacity(uint8_t opacity)
+void FastTMXLayer::setOpacity(uint8_t opacity)
{
Node::setOpacity(opacity);
_quadsDirty = true;
}
-void TMXLayer::updateTotalQuads()
+void FastTMXLayer::updateTotalQuads()
{
if(_quadsDirty)
{
@@ -476,12 +477,12 @@ void TMXLayer::updateTotalQuads()
if (_texture->hasPremultipliedAlpha())
{
- color.r *= color.a / 255.0f;
- color.g *= color.a / 255.0f;
- color.b *= color.a / 255.0f;
+ auto alpha = color.a / 255.0f;
+ color.r = static_cast(color.r * alpha);
+ color.g = static_cast(color.g * alpha);
+ color.b = static_cast(color.b * alpha);
}
-
int quadIndex = 0;
for(int y = 0; y < _layerSize.height; ++y)
{
@@ -501,11 +502,12 @@ void TMXLayer::updateTotalQuads()
float left, right, top, bottom, z;
- z = getVertexZForPos(Vec2(x, y));
- auto iter = _indicesVertexZOffsets.find(z);
+ int zPos = getVertexZForPos(Vec2((float)x, (float)y));
+ z = (float)zPos;
+ auto iter = _indicesVertexZOffsets.find(zPos);
if(iter == _indicesVertexZOffsets.end())
{
- _indicesVertexZOffsets[z] = 1;
+ _indicesVertexZOffsets[zPos] = 1;
}
else
{
@@ -603,7 +605,7 @@ void TMXLayer::updateTotalQuads()
}
// removing / getting tiles
-Sprite* TMXLayer::getTileAt(const Vec2& tileCoordinate)
+Sprite* FastTMXLayer::getTileAt(const Vec2& tileCoordinate)
{
CCASSERT( tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position");
CCASSERT( _tiles, "TMXLayer: the tiles map has been released");
@@ -613,7 +615,7 @@ Sprite* TMXLayer::getTileAt(const Vec2& tileCoordinate)
// if GID == 0, then no tile is present
if( gid ) {
- int index = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width;
+ int index = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width);
auto it = _spriteContainer.find(index);
if (it != _spriteContainer.end())
@@ -643,7 +645,7 @@ Sprite* TMXLayer::getTileAt(const Vec2& tileCoordinate)
return tile;
}
-int TMXLayer::getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags/* = nullptr*/)
+int FastTMXLayer::getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags/* = nullptr*/)
{
CCASSERT(tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles, "TMXLayer: the tiles map has been released");
@@ -669,12 +671,12 @@ int TMXLayer::getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags/* = n
return (tile & kTMXFlippedMask);
}
-Vec2 TMXLayer::getPositionAt(const Vec2& pos)
+Vec2 FastTMXLayer::getPositionAt(const Vec2& pos)
{
return PointApplyTransform(pos, _tileToNodeTransform);
}
-int TMXLayer::getVertexZForPos(const Vec2& pos)
+int FastTMXLayer::getVertexZForPos(const Vec2& pos)
{
int ret = 0;
int maxVal = 0;
@@ -705,7 +707,7 @@ int TMXLayer::getVertexZForPos(const Vec2& pos)
return ret;
}
-void TMXLayer::removeTileAt(const Vec2& tileCoordinate)
+void FastTMXLayer::removeTileAt(const Vec2& tileCoordinate)
{
CCASSERT( tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position");
@@ -714,7 +716,7 @@ void TMXLayer::removeTileAt(const Vec2& tileCoordinate)
if( gid ) {
- int z = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width;
+ int z = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width);
// remove tile from GID map
setFlaggedTileGIDByIndex(z, 0);
@@ -728,7 +730,7 @@ void TMXLayer::removeTileAt(const Vec2& tileCoordinate)
}
}
-void TMXLayer::setFlaggedTileGIDByIndex(int index, uint32_t gid)
+void FastTMXLayer::setFlaggedTileGIDByIndex(int index, uint32_t gid)
{
if(gid == _tiles[index]) return;
_tiles[index] = gid;
@@ -736,7 +738,7 @@ void TMXLayer::setFlaggedTileGIDByIndex(int index, uint32_t gid)
_dirty = true;
}
-void TMXLayer::removeChild(Node* node, bool cleanup)
+void FastTMXLayer::removeChild(Node* node, bool cleanup)
{
int tag = node->getTag();
auto it = _spriteContainer.find(tag);
@@ -748,7 +750,7 @@ void TMXLayer::removeChild(Node* node, bool cleanup)
}
// TMXLayer - Properties
-Value TMXLayer::getProperty(const std::string& propertyName) const
+Value FastTMXLayer::getProperty(const std::string& propertyName) const
{
auto propItr = _properties.find(propertyName);
if (propItr != _properties.end())
@@ -757,7 +759,7 @@ Value TMXLayer::getProperty(const std::string& propertyName) const
return Value();
}
-void TMXLayer::parseInternalProperties()
+void FastTMXLayer::parseInternalProperties()
{
auto vertexz = getProperty("cc_vertexz");
if (vertexz.isNull()) return;
@@ -777,7 +779,7 @@ void TMXLayer::parseInternalProperties()
}
//CCTMXLayer2 - obtaining positions, offset
-Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
+Vec2 FastTMXLayer::calculateLayerOffset(const Vec2& pos)
{
Vec2 ret;
switch (_layerOrientation)
@@ -798,12 +800,12 @@ Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
}
// TMXLayer - adding / remove tiles
-void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate)
+void FastTMXLayer::setTileGID(int gid, const Vec2& tileCoordinate)
{
setTileGID(gid, tileCoordinate, (TMXTileFlags)0);
}
-void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flags)
+void FastTMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flags)
{
CCASSERT(tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position");
CCASSERT(_tiles, "TMXLayer: the tiles map has been released");
@@ -824,13 +826,13 @@ void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flag
// empty tile. create a new one
else if (currentGID == 0)
{
- int z = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width;
+ int z = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width);
setFlaggedTileGIDByIndex(z, gidAndFlags);
}
// modifying an existing tile with a non-empty tile
else
{
- int z = (int) tileCoordinate.x + (int) tileCoordinate.y * _layerSize.width;
+ int z = (int) tileCoordinate.x + (int)(tileCoordinate.y * _layerSize.width);
auto it = _spriteContainer.find(z);
if (it != _spriteContainer.end())
{
@@ -854,7 +856,7 @@ void TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flag
}
}
-void TMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, uint32_t gid)
+void FastTMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, uint32_t gid)
{
sprite->setPosition(getPositionAt(pos));
sprite->setPositionZ((float)getVertexZForPos(pos));
@@ -910,11 +912,10 @@ void TMXLayer::setupTileSprite(Sprite* sprite, const Vec2& pos, uint32_t gid)
}
}
-std::string TMXLayer::getDescription() const
+std::string FastTMXLayer::getDescription() const
{
return StringUtils::format("", _tag, (int)_mapTileSize.width, (int)_mapTileSize.height);
}
-} //end of namespace experimental
NS_CC_END
diff --git a/cocos/2d/CCFastTMXLayer.h b/cocos/2d/CCFastTMXLayer.h
index db8c92ab0d..f50bf7608b 100644
--- a/cocos/2d/CCFastTMXLayer.h
+++ b/cocos/2d/CCFastTMXLayer.h
@@ -45,8 +45,6 @@ namespace backend
class Buffer;
}
-namespace experimental{
-
/**
* @addtogroup _2d
* @{
@@ -78,7 +76,7 @@ namespace experimental{
* @js NA
*/
-class CC_DLL TMXLayer : public Node
+class CC_DLL FastTMXLayer : public Node
{
public:
/** Possible orientations of the TMX map */
@@ -93,16 +91,16 @@ public:
* @param mapInfo A map info.
* @return Return an autorelease object.
*/
- static TMXLayer * create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
+ static FastTMXLayer * create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
/**
* @js ctor
*/
- TMXLayer();
+ FastTMXLayer();
/**
* @js NA
* @lua NA
*/
- virtual ~TMXLayer();
+ virtual ~FastTMXLayer();
/** Returns the tile gid at a given tile coordinate. It also returns the tile flags.
*
@@ -278,7 +276,7 @@ public:
void removeChild(Node* child, bool cleanup = true) override;
protected:
- virtual void setOpacity(GLubyte opacity) override;
+ virtual void setOpacity(uint8_t opacity) override;
bool initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
void updateTiles(const Rect& culledRect);
@@ -361,5 +359,4 @@ protected:
// end of tilemap_parallax_nodes group
/// @}
-} //end of namespace experimental
NS_CC_END
diff --git a/cocos/2d/CCFastTMXTiledMap.cpp b/cocos/2d/CCFastTMXTiledMap.cpp
index 7a29a3bb18..1a7e5ffff1 100644
--- a/cocos/2d/CCFastTMXTiledMap.cpp
+++ b/cocos/2d/CCFastTMXTiledMap.cpp
@@ -30,13 +30,12 @@ THE SOFTWARE.
#include "base/ccUTF8.h"
NS_CC_BEGIN
-namespace experimental {
// implementation FastTMXTiledMap
-TMXTiledMap * TMXTiledMap::create(const std::string& tmxFile)
+FastTMXTiledMap * FastTMXTiledMap::create(const std::string& tmxFile)
{
- TMXTiledMap *ret = new (std::nothrow) TMXTiledMap();
+ FastTMXTiledMap *ret = new (std::nothrow) FastTMXTiledMap();
if (ret->initWithTMXFile(tmxFile))
{
ret->autorelease();
@@ -46,9 +45,9 @@ TMXTiledMap * TMXTiledMap::create(const std::string& tmxFile)
return nullptr;
}
-TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std::string& resourcePath)
+FastTMXTiledMap* FastTMXTiledMap::createWithXML(const std::string& tmxString, const std::string& resourcePath)
{
- TMXTiledMap *ret = new (std::nothrow) TMXTiledMap();
+ FastTMXTiledMap *ret = new (std::nothrow) FastTMXTiledMap();
if (ret->initWithXML(tmxString, resourcePath))
{
ret->autorelease();
@@ -58,7 +57,7 @@ TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std:
return nullptr;
}
-bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
+bool FastTMXTiledMap::initWithTMXFile(const std::string& tmxFile)
{
CCASSERT(tmxFile.size()>0, "FastTMXTiledMap: tmx file should not be empty");
@@ -76,7 +75,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
return true;
}
-bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath)
+bool FastTMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath)
{
setContentSize(Size::ZERO);
@@ -88,24 +87,24 @@ bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& r
return true;
}
-TMXTiledMap::TMXTiledMap()
+FastTMXTiledMap::FastTMXTiledMap()
:_mapSize(Size::ZERO)
,_tileSize(Size::ZERO)
{
}
-TMXTiledMap::~TMXTiledMap()
+FastTMXTiledMap::~FastTMXTiledMap()
{
}
// private
-TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
+FastTMXLayer * FastTMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo);
if (tileset == nullptr)
return nullptr;
- TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo);
+ FastTMXLayer *layer = FastTMXLayer::create(tileset, layerInfo, mapInfo);
// tell the layerinfo to release the ownership of the tiles map.
layerInfo->_ownTiles = false;
@@ -114,7 +113,7 @@ TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
return layer;
}
-TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
+TMXTilesetInfo * FastTMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
Size size = layerInfo->_layerSize;
auto& tilesets = mapInfo->getTilesets();
@@ -158,7 +157,7 @@ TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInf
return nullptr;
}
-void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
+void FastTMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
{
_mapSize = mapInfo->getMapSize();
_tileSize = mapInfo->getTileSize();
@@ -176,7 +175,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
for(const auto &layerInfo : layers) {
if (layerInfo->_visible)
{
- TMXLayer *child = parseLayer(layerInfo, mapInfo);
+ FastTMXLayer *child = parseLayer(layerInfo, mapInfo);
if (child == nullptr) {
idx++;
continue;
@@ -196,13 +195,13 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
}
// public
-TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const
+FastTMXLayer * FastTMXTiledMap::getLayer(const std::string& layerName) const
{
CCASSERT(layerName.size() > 0, "Invalid layer name!");
for (auto& child : _children)
{
- TMXLayer* layer = dynamic_cast(child);
+ FastTMXLayer* layer = dynamic_cast(child);
if(layer)
{
if(layerName.compare( layer->getLayerName()) == 0)
@@ -216,7 +215,7 @@ TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const
return nullptr;
}
-TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const
+TMXObjectGroup * FastTMXTiledMap::getObjectGroup(const std::string& groupName) const
{
CCASSERT(groupName.size() > 0, "Invalid group name!");
@@ -235,7 +234,7 @@ TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const
return nullptr;
}
-Value TMXTiledMap::getProperty(const std::string& propertyName) const
+Value FastTMXTiledMap::getProperty(const std::string& propertyName) const
{
auto propsItr = _properties.find(propertyName);
if (propsItr != _properties.end())
@@ -244,7 +243,7 @@ Value TMXTiledMap::getProperty(const std::string& propertyName) const
return Value();
}
-Value TMXTiledMap::getPropertiesForGID(int GID) const
+Value FastTMXTiledMap::getPropertiesForGID(int GID) const
{
auto propsItr = _tileProperties.find(GID);
if (propsItr != _tileProperties.end())
@@ -253,12 +252,9 @@ Value TMXTiledMap::getPropertiesForGID(int GID) const
return Value();
}
-std::string TMXTiledMap::getDescription() const
+std::string FastTMXTiledMap::getDescription() const
{
return StringUtils::format("(_children.size()));
}
-} //end of namespace experimental
-
NS_CC_END
-
diff --git a/cocos/2d/CCFastTMXTiledMap.h b/cocos/2d/CCFastTMXTiledMap.h
index 477761ca45..9b344dd8f6 100644
--- a/cocos/2d/CCFastTMXTiledMap.h
+++ b/cocos/2d/CCFastTMXTiledMap.h
@@ -25,8 +25,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-#ifndef __CC_FAST_TMX_TILEMAP_H__
-#define __CC_FAST_TMX_TILEMAP_H__
+#pragma once
#include "2d/CCNode.h"
#include "2d/CCTMXObjectGroup.h"
@@ -36,10 +35,7 @@ NS_CC_BEGIN
class TMXLayerInfo;
class TMXTilesetInfo;
class TMXMapInfo;
-
-namespace experimental {
-
-class TMXLayer;
+class FastTMXLayer;
/**
* @addtogroup _2d
* @{
@@ -97,14 +93,14 @@ class TMXLayer;
* @since v3.2
* @js NA
*/
-class CC_DLL TMXTiledMap : public Node
+class CC_DLL FastTMXTiledMap : public Node
{
public:
/** Creates a TMX Tiled Map with a TMX file.
*
* @return An autorelease object.
*/
- static TMXTiledMap* create(const std::string& tmxFile);
+ static FastTMXTiledMap* create(const std::string& tmxFile);
/** Initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources.
*
@@ -112,13 +108,13 @@ public:
* @param resourcePath A path to TMX resources.
* @return An autorelease object.
*/
- static TMXTiledMap* createWithXML(const std::string& tmxString, const std::string& resourcePath);
+ static FastTMXTiledMap* createWithXML(const std::string& tmxString, const std::string& resourcePath);
/** Return the FastTMXLayer for the specific layer.
*
* @return Return the FastTMXLayer for the specific layer.
*/
- TMXLayer* getLayer(const std::string& layerName) const;
+ FastTMXLayer* getLayer(const std::string& layerName) const;
/** Return the TMXObjectGroup for the specific group.
*
@@ -209,12 +205,12 @@ protected:
/**
* @js ctor
*/
- TMXTiledMap();
+ FastTMXTiledMap();
/**
* @js NA
* @lua NA
*/
- virtual ~TMXTiledMap();
+ virtual ~FastTMXTiledMap();
/** initializes a TMX Tiled Map with a TMX file */
bool initWithTMXFile(const std::string& tmxFile);
@@ -222,7 +218,7 @@ protected:
/** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
bool initWithXML(const std::string& tmxString, const std::string& resourcePath);
- TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
+ FastTMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
void buildWithMapInfo(TMXMapInfo* mapInfo);
@@ -241,17 +237,12 @@ protected:
ValueMapIntKey _tileProperties;
private:
- CC_DISALLOW_COPY_AND_ASSIGN(TMXTiledMap);
+ CC_DISALLOW_COPY_AND_ASSIGN(FastTMXTiledMap);
};
// end of tilemap_parallax_nodes group
/** @} */
-} //end of namespace experimental
NS_CC_END
-
-#endif //__CCTMX_TILE_MAP2_H__
-
-
diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp
index fbe43779cc..5818b2c204 100644
--- a/cocos/2d/CCFontAtlas.cpp
+++ b/cocos/2d/CCFontAtlas.cpp
@@ -52,7 +52,7 @@ FontAtlas::FontAtlas(Font &theFont)
_fontFreeType = dynamic_cast(_font);
if (_fontFreeType)
{
- _lineHeight = _font->getFontMaxHeight();
+ _lineHeight = (float)_font->getFontMaxHeight();
_fontAscender = _fontFreeType->getFontAscender();
_letterEdgeExtend = 2;
@@ -60,6 +60,13 @@ FontAtlas::FontAtlas(Font &theFont)
{
_letterPadding += 2 * FontFreeType::DistanceMapSpread;
}
+
+ auto outlineSize = _fontFreeType->getOutlineSize();
+ if (outlineSize > 0)
+ {
+ _lineHeight += 2 * outlineSize;
+ }
+
#if CC_ENABLE_CACHE_TEXTURE_DATA
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
@@ -87,7 +94,6 @@ void FontAtlas::reinit()
auto outlineSize = _fontFreeType->getOutlineSize();
if(outlineSize > 0)
{
- _lineHeight += 2 * outlineSize;
_currentPageDataSize *= 2;
_currentPageDataSizeRGBA = _currentPageDataSize * 2;
@@ -203,7 +209,7 @@ void FontAtlas::scaleFontLetterDefinition(float scaleFactor)
letterDefinition.height *= scaleFactor;
letterDefinition.offsetX *= scaleFactor;
letterDefinition.offsetY *= scaleFactor;
- letterDefinition.xAdvance *= scaleFactor;
+ letterDefinition.xAdvance = (int)(letterDefinition.xAdvance * scaleFactor);
}
}
@@ -379,7 +385,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
auto scaleFactor = CC_CONTENT_SCALE_FACTOR();
auto pixelFormat = _fontFreeType->getOutlineSize() > 0 ? backend::PixelFormat::AI88 : backend::PixelFormat::A8;
- float startY = _currentPageOrigY;
+ int startY = (int)_currentPageOrigY;
for (auto&& it : codeMapOfNewChar)
{
@@ -401,7 +407,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
{
updateTextureContent(pixelFormat, startY);
- startY = 0.0f;
+ startY = 0;
_currentPageOrigY = 0;
memset(_currentPageData, 0, _currentPageDataSize);
@@ -428,7 +434,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
{
_currLineHeight = glyphHeight;
}
- _fontFreeType->renderCharAt(_currentPageData, _currentPageOrigX + adjustForExtend, _currentPageOrigY + adjustForExtend, bitmap, bitmapWidth, bitmapHeight);
+ _fontFreeType->renderCharAt(_currentPageData, (int)_currentPageOrigX + adjustForExtend, (int)_currentPageOrigY + adjustForExtend, bitmap, bitmapWidth, bitmapHeight);
tempDef.U = _currentPageOrigX;
tempDef.V = _currentPageOrigY;
@@ -471,7 +477,7 @@ void FontAtlas::updateTextureContent(backend::PixelFormat format, int startY)
auto outlineSize = _fontFreeType->getOutlineSize();
if (outlineSize > 0 && format == backend::PixelFormat::AI88)
{
- int nLen = CacheTextureWidth * (_currentPageOrigY - startY + _currLineHeight);
+ int nLen = CacheTextureWidth * ((int)_currentPageOrigY - startY + _currLineHeight);
data = _currentPageData + CacheTextureWidth * (int)startY * 2;
memset(_currentPageDataRGBA, 0, 4 * nLen);
for (auto i = 0; i < nLen; i++)
@@ -479,12 +485,12 @@ void FontAtlas::updateTextureContent(backend::PixelFormat format, int startY)
_currentPageDataRGBA[i*4] = data[i*2];
_currentPageDataRGBA[i*4+3] = data[i*2+1];
}
- _atlasTextures[_currentPage]->updateWithData(_currentPageDataRGBA, 0, startY, CacheTextureWidth, _currentPageOrigY - startY + _currLineHeight);
+ _atlasTextures[_currentPage]->updateWithData(_currentPageDataRGBA, 0, startY, CacheTextureWidth, (int)_currentPageOrigY - startY + _currLineHeight);
}
else
{
data = _currentPageData + CacheTextureWidth * (int)startY;
- _atlasTextures[_currentPage]->updateWithData(data, 0, startY, CacheTextureWidth, _currentPageOrigY - startY + _currLineHeight);
+ _atlasTextures[_currentPage]->updateWithData(data, 0, startY, CacheTextureWidth, (int)_currentPageOrigY - startY + _currLineHeight);
}
}
diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp
index 790f67cdd9..6240c16a3d 100644
--- a/cocos/2d/CCFontAtlasCache.cpp
+++ b/cocos/2d/CCFontAtlasCache.cpp
@@ -71,7 +71,7 @@ FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config)
if ( it == _atlasMap.end() )
{
auto font = FontFreeType::create(realFontFilename, config->fontSize, config->glyphs,
- config->customGlyphs, useDistanceField, config->outlineSize);
+ config->customGlyphs, useDistanceField, (float)config->outlineSize);
if (font)
{
auto tempAtlas = font->createFontAtlas();
diff --git a/cocos/2d/CCFontCharMap.cpp b/cocos/2d/CCFontCharMap.cpp
index ab958166ab..ee4f1b796b 100644
--- a/cocos/2d/CCFontCharMap.cpp
+++ b/cocos/2d/CCFontCharMap.cpp
@@ -114,7 +114,7 @@ FontAtlas * FontCharMap::createFontAtlas()
int itemsPerColumn = (int)(s.height / _itemHeight);
int itemsPerRow = (int)(s.width / _itemWidth);
- tempAtlas->setLineHeight(_itemHeight);
+ tempAtlas->setLineHeight((float)_itemHeight);
auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp
index daa5720810..4724e13450 100644
--- a/cocos/2d/CCFontFNT.cpp
+++ b/cocos/2d/CCFontFNT.cpp
@@ -617,7 +617,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffse
}
FontFNT *tempFont = new FontFNT(newConf,imageOffset);
- tempFont->setFontSize(newConf->_fontSize);
+ tempFont->setFontSize((float)newConf->_fontSize);
if (!tempFont)
{
return nullptr;
@@ -713,7 +713,7 @@ FontAtlas * FontFNT::createFontAtlas()
// common height
int originalFontSize = _configuration->_fontSize;
- float originalLineHeight = _configuration->_commonHeight;
+ float originalLineHeight = (float)_configuration->_commonHeight;
float factor = 0.0f;
if (std::abs(_fontSize - originalFontSize) < FLT_EPSILON) {
factor = 1.0f;
diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp
index 78e82b6bf8..63d36d391e 100644
--- a/cocos/2d/CCFontFreeType.cpp
+++ b/cocos/2d/CCFontFreeType.cpp
@@ -257,13 +257,13 @@ int * FontFreeType::getHorizontalKerningForTextUTF32(const std::u32string& text,
int FontFreeType::getHorizontalKerningForChars(uint64_t firstChar, uint64_t secondChar) const
{
// get the ID to the char we need
- int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar);
+ int glyphIndex1 = FT_Get_Char_Index(_fontRef, static_cast(firstChar));
if (!glyphIndex1)
return 0;
// get the ID to the char we need
- int glyphIndex2 = FT_Get_Char_Index(_fontRef, secondChar);
+ int glyphIndex2 = FT_Get_Char_Index(_fontRef, static_cast(secondChar));
if (!glyphIndex2)
return 0;
@@ -301,20 +301,20 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo
if (_distanceFieldEnabled)
{
- if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT))
+ if (FT_Load_Char(_fontRef, static_cast(theChar), FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT))
break;
}
else
{
- if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT))
+ if (FT_Load_Char(_fontRef, static_cast(theChar), FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT))
break;
}
auto& metrics = _fontRef->glyph->metrics;
- outRect.origin.x = metrics.horiBearingX >> 6;
- outRect.origin.y = -(metrics.horiBearingY >> 6);
- outRect.size.width = (metrics.width >> 6);
- outRect.size.height = (metrics.height >> 6);
+ outRect.origin.x = static_cast(metrics.horiBearingX >> 6);
+ outRect.origin.y = static_cast(-(metrics.horiBearingY >> 6));
+ outRect.size.width = static_cast((metrics.width >> 6));
+ outRect.size.height = static_cast((metrics.height >> 6));
xAdvance = (static_cast(_fontRef->glyph->metrics.horiAdvance >> 6));
@@ -336,10 +336,10 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo
break;
}
- long glyphMinX = outRect.origin.x;
- long glyphMaxX = outRect.origin.x + outWidth;
- long glyphMinY = -outHeight - outRect.origin.y;
- long glyphMaxY = -outRect.origin.y;
+ int glyphMinX = (int)outRect.origin.x;
+ int glyphMaxX = (int)(outRect.origin.x + outWidth);
+ int glyphMinY = (int)(-outHeight - outRect.origin.y);
+ int glyphMaxY = (int)-outRect.origin.y;
auto outlineMinX = bbox.xMin >> 6;
auto outlineMaxX = bbox.xMax >> 6;
@@ -353,15 +353,16 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo
auto blendWidth = MAX(outlineMaxX, glyphMaxX) - blendImageMinX;
auto blendHeight = blendImageMaxY - MIN(outlineMinY, glyphMinY);
- outRect.origin.x = blendImageMinX;
+ outRect.origin.x = (float)blendImageMinX;
outRect.origin.y = -blendImageMaxY + _outlineSize;
unsigned char *blendImage = nullptr;
if (blendWidth > 0 && blendHeight > 0)
{
- long index, index2;
- blendImage = new (std::nothrow) unsigned char[blendWidth * blendHeight * 2];
- memset(blendImage, 0, blendWidth * blendHeight * 2);
+ FT_Pos index, index2;
+ auto imageSize = blendWidth * blendHeight * 2;
+ blendImage = new (std::nothrow) unsigned char[imageSize];
+ memset(blendImage, 0, imageSize);
auto px = outlineMinX - blendImageMinX;
auto py = blendImageMaxY - outlineMaxY;
@@ -388,8 +389,8 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo
}
}
- outRect.size.width = blendWidth;
- outRect.size.height = blendHeight;
+ outRect.size.width = (float)blendWidth;
+ outRect.size.height = (float)blendHeight;
outWidth = blendWidth;
outHeight = blendHeight;
@@ -418,7 +419,7 @@ unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar, long &outWidth, lo
unsigned char * FontFreeType::getGlyphBitmapWithOutline(uint64_t theChar, FT_BBox &bbox)
{
unsigned char* ret = nullptr;
- if (FT_Load_Char(_fontRef, theChar, FT_LOAD_NO_BITMAP) == 0)
+ if (FT_Load_Char(_fontRef, static_cast(theChar), FT_LOAD_NO_BITMAP) == 0)
{
if (_fontRef->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
{
diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp
index efd0f1559c..3517a0b3a1 100644
--- a/cocos/2d/CCGrid.cpp
+++ b/cocos/2d/CCGrid.cpp
@@ -32,9 +32,10 @@ THE SOFTWARE.
#include "renderer/CCRenderer.h"
#include "renderer/CCTexture2D.h"
#include "renderer/ccShaders.h"
+#include "renderer/backend/ProgramState.h"
#include "renderer/backend/Device.h"
#include "2d/CCCamera.h"
-#include "renderer/backend/ProgramState.h"
+
NS_CC_BEGIN
// implementation of GridBase
@@ -108,7 +109,8 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipp
auto& pipelineDescriptor = _drawCommand.getPipelineDescriptor();
CC_SAFE_RELEASE(_programState);
- _programState = new (std::nothrow) backend::ProgramState(positionTexture_vert, positionTexture_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
_mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
@@ -212,7 +214,7 @@ void GridBase::beforeDraw()
_directorProjection = director->getProjection();
set2DProjection();
Size size = director->getWinSizeInPixels();
- renderer->setViewPort(0, 0, size.width, size.height);
+ renderer->setViewPort(0, 0, (unsigned int)size.width, (unsigned int)size.height);
RenderTargetFlag flags = RenderTargetFlag::COLOR;
_oldColorAttachment = renderer->getColorAttachment();
@@ -407,20 +409,20 @@ void Grid3D::calculateVertexPoints()
float height = (float)_texture->getPixelsHigh();
float imageH = _texture->getContentSizeInPixels().height;
- size_t x = 0, y = 0, i = 0;
+ int x = 0, y = 0, i = 0;
CC_SAFE_FREE(_vertices);
CC_SAFE_FREE(_originalVertices);
CC_SAFE_FREE(_texCoordinates);
CC_SAFE_FREE(_vertexBuffer);
CC_SAFE_FREE(_indices);
- size_t numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
+ size_t numOfPoints = static_cast((_gridSize.width+1) * (_gridSize.height+1));
_vertices = malloc(numOfPoints * sizeof(Vec3));
_originalVertices = malloc(numOfPoints * sizeof(Vec3));
_texCoordinates = malloc(numOfPoints * sizeof(Vec2));
_vertexBuffer = malloc(numOfPoints * (sizeof(Vec3) + sizeof(Vec2)));
- _indices = (unsigned short*)malloc(_gridSize.width * _gridSize.height * sizeof(unsigned short) * 6);
+ _indices = (unsigned short*)malloc(static_cast(_gridSize.width * _gridSize.height * sizeof(unsigned short) * 6));
float *vertArray = (float*)_vertices;
float *texArray = (float*)_texCoordinates;
@@ -430,7 +432,7 @@ void Grid3D::calculateVertexPoints()
{
for (y = 0; y < _gridSize.height; ++y)
{
- int idx = (y * _gridSize.width) + x;
+ int idx = (int)(y * _gridSize.width) + x;
float x1 = x * _step.x + _gridRect.origin.x;
float x2 = x1 + _step.x;
@@ -479,14 +481,14 @@ void Grid3D::calculateVertexPoints()
updateVertexAndTexCoordinate();
- memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3));
+ memcpy(_originalVertices, _vertices, static_cast((_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3)));
}
Vec3 Grid3D::getVertex(const Vec2& pos) const
{
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
- int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
+ int index = (int)(pos.x * (_gridSize.height+1) + pos.y) * 3;
float *vertArray = (float*)_vertices;
Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
@@ -498,7 +500,7 @@ Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const
{
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
- int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
+ int index = (int)(pos.x * (_gridSize.height+1) + pos.y) * 3;
float *vertArray = (float*)_originalVertices;
Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
@@ -509,7 +511,7 @@ Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const
void Grid3D::setVertex(const Vec2& pos, const Vec3& vertex)
{
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
- int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3;
+ int index = (int)(pos.x * (_gridSize.height + 1) + pos.y) * 3;
float *vertArray = (float*)_vertices;
vertArray[index] = vertex.x;
vertArray[index+1] = vertex.y;
@@ -520,14 +522,14 @@ void Grid3D::reuse()
{
if (_reuseGrid > 0)
{
- memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3));
+ memcpy(_originalVertices, _vertices, static_cast((_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3)));
--_reuseGrid;
}
}
void Grid3D::updateVertexBuffer()
{
- size_t numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
+ size_t numOfPoints = static_cast((_gridSize.width+1) * (_gridSize.height+1));
auto tempVecPointer = (Vec3*)_vertices;
for (size_t i = 0; i < numOfPoints; ++i)
{
@@ -536,15 +538,15 @@ void Grid3D::updateVertexBuffer()
}
_drawCommand.updateVertexBuffer(_vertexBuffer, (unsigned int)(numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2)) );
- _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short));
+ _drawCommand.updateIndexBuffer(_indices, static_cast(_gridSize.width * _gridSize.height * 6 * sizeof(unsigned short)));
}
void Grid3D::updateVertexAndTexCoordinate()
{
- unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
+ unsigned int numOfPoints = static_cast((_gridSize.width+1) * (_gridSize.height+1));
auto tempVecPointer = (Vec3*)_vertices;
auto tempTexPointer = (Vec2*)_texCoordinates;
- for (size_t i = 0; i < numOfPoints; ++i)
+ for (unsigned int i = 0; i < numOfPoints; ++i)
{
auto offset = i * (sizeof(Vec3) + sizeof(Vec2));
memcpy((char*)_vertexBuffer + offset, &tempVecPointer[i], sizeof(Vec3));
@@ -553,8 +555,9 @@ void Grid3D::updateVertexAndTexCoordinate()
_drawCommand.createVertexBuffer((unsigned int)(sizeof(Vec3) + sizeof(Vec2)), numOfPoints, CustomCommand::BufferUsage::DYNAMIC);
_drawCommand.updateVertexBuffer(_vertexBuffer, numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2));
- _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, _gridSize.width * _gridSize.height * 6, CustomCommand::BufferUsage::DYNAMIC);
- _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short));
+ unsigned int capacity = (unsigned int)(_gridSize.width * _gridSize.height) * 6;
+ _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, capacity, CustomCommand::BufferUsage::DYNAMIC);
+ _drawCommand.updateIndexBuffer(_indices, capacity * sizeof(unsigned short));
}
// implementation of TiledGrid3D
@@ -663,7 +666,7 @@ void TiledGrid3D::calculateVertexPoints()
float height = (float)_texture->getPixelsHigh();
float imageH = _texture->getContentSizeInPixels().height;
- int numQuads = _gridSize.width * _gridSize.height;
+ int numQuads = (int)(_gridSize.width * _gridSize.height);
CC_SAFE_FREE(_vertices);
CC_SAFE_FREE(_originalVertices);
CC_SAFE_FREE(_texCoordinates);
@@ -741,7 +744,7 @@ void TiledGrid3D::calculateVertexPoints()
void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords)
{
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
- int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
+ int idx = (int)(_gridSize.height * pos.x + pos.y) * 4 * 3;
float *vertArray = (float*)_vertices;
memcpy(&vertArray[idx], &coords, sizeof(Quad3));
}
@@ -749,7 +752,7 @@ void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords)
Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const
{
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
- int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
+ int idx = (int)(_gridSize.height * pos.x + pos.y) * 4 * 3;
float *vertArray = (float*)_originalVertices;
Quad3 ret;
@@ -761,7 +764,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const
Quad3 TiledGrid3D::getTile(const Vec2& pos) const
{
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
- int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
+ int idx = (int)(_gridSize.height * pos.x + pos.y) * 4 * 3;
float *vertArray = (float*)_vertices;
Quad3 ret;
@@ -774,7 +777,7 @@ void TiledGrid3D::reuse()
{
if (_reuseGrid > 0)
{
- int numQuads = _gridSize.width * _gridSize.height;
+ int numQuads = (int)(_gridSize.width * _gridSize.height);
memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(float));
--_reuseGrid;
@@ -783,7 +786,8 @@ void TiledGrid3D::reuse()
void TiledGrid3D::updateVertexBuffer()
{
- size_t numOfPoints = _gridSize.width * _gridSize.height * 4;
+ size_t gradSize = static_cast(_gridSize.width * _gridSize.height);
+ size_t numOfPoints = gradSize * 4;
auto tempVecPointer = (Vec3*)_vertices;
for (size_t i = 0; i < numOfPoints; ++i)
{
@@ -792,12 +796,13 @@ void TiledGrid3D::updateVertexBuffer()
}
_drawCommand.updateVertexBuffer(_vertexBuffer, (unsigned int)(numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2)) );
- _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short));
+ _drawCommand.updateIndexBuffer(_indices, gradSize * 6 * sizeof(unsigned short));
}
void TiledGrid3D::updateVertexAndTexCoordinate()
{
- unsigned int numOfPoints = _gridSize.width * _gridSize.height * 4;
+ size_t gradSize = static_cast(_gridSize.width * _gridSize.height);
+ auto numOfPoints = gradSize * 4;
auto tempVecPointer = (Vec3*)_vertices;
auto tempTexPointer = (Vec2*)_texCoordinates;
for (size_t i = 0; i < numOfPoints; ++i)
@@ -806,11 +811,11 @@ void TiledGrid3D::updateVertexAndTexCoordinate()
memcpy((char*)_vertexBuffer + offset, &tempVecPointer[i], sizeof(Vec3));
memcpy((char*)_vertexBuffer + offset + sizeof(Vec3), &tempTexPointer[i], sizeof(Vec2));
}
- _drawCommand.createVertexBuffer((unsigned int)(sizeof(Vec3) + sizeof(Vec2) ), numOfPoints, CustomCommand::BufferUsage::DYNAMIC);
+ _drawCommand.createVertexBuffer((sizeof(Vec3) + sizeof(Vec2) ), numOfPoints, CustomCommand::BufferUsage::DYNAMIC);
_drawCommand.updateVertexBuffer(_vertexBuffer, numOfPoints * sizeof(Vec3) + numOfPoints * sizeof(Vec2));
- _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, _gridSize.width * _gridSize.height * 6, CustomCommand::BufferUsage::DYNAMIC);
- _drawCommand.updateIndexBuffer(_indices, _gridSize.width * _gridSize.height * 6 * sizeof(unsigned short));
+ _drawCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT, gradSize * 6, CustomCommand::BufferUsage::DYNAMIC);
+ _drawCommand.updateIndexBuffer(_indices, gradSize * 6 * sizeof(unsigned short));
}
NS_CC_END
diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp
index 055d9b6138..b06c151702 100644
--- a/cocos/2d/CCLabel.cpp
+++ b/cocos/2d/CCLabel.cpp
@@ -25,9 +25,9 @@
****************************************************************************/
#include "2d/CCLabel.h"
-
#include
-
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCFont.h"
#include "2d/CCFontAtlasCache.h"
#include "2d/CCFontAtlas.h"
@@ -688,7 +688,8 @@ void Label::updateShaderProgram()
}
CC_SAFE_RELEASE(_programState);
- _programState = new backend::ProgramState(programType);
+ auto* program = backend::Program::getBuiltinProgram(programType);
+ _programState = new backend::ProgramState(program);
updateUniformLocations();
@@ -1568,7 +1569,7 @@ void Label::updateContent()
// FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is POT
y += spriteSize.height / 2;
// FIXME: Might not work with different vertical alignments
- _underlineNode->drawLine(Vec2(0,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor()));
+ _underlineNode->drawLine(Vec2(0.0f,y), Vec2(spriteSize.width,y), Color4F(_textSprite->getDisplayedColor()));
}
}
@@ -1581,9 +1582,9 @@ void Label::updateContent()
Vec2 vertices[4] =
{
Vec2::ZERO,
- Vec2(_contentSize.width, 0),
+ Vec2(_contentSize.width, 0.0f),
Vec2(_contentSize.width, _contentSize.height),
- Vec2(0, _contentSize.height)
+ Vec2(0.0f, _contentSize.height)
};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F::WHITE);
#endif
diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp
index 27b40f9061..9fa24cada0 100644
--- a/cocos/2d/CCLabelAtlas.cpp
+++ b/cocos/2d/CCLabelAtlas.cpp
@@ -264,7 +264,7 @@ void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
Vec2::ZERO,
Vec2(size.width, 0),
Vec2(size.width, size.height),
- Vec2(0, size.height)
+ Vec2(0.0f, size.height)
};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
}
diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp
index 602834e78a..941b2e4ab9 100644
--- a/cocos/2d/CCLayer.cpp
+++ b/cocos/2d/CCLayer.cpp
@@ -288,7 +288,8 @@ LayerColor::LayerColor()
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(positionColor_vert, positionColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
auto vertexLayout = _programState->getVertexLayout();
@@ -705,7 +706,8 @@ LayerRadialGradient* LayerRadialGradient::create()
LayerRadialGradient::LayerRadialGradient()
{
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(position_vert, layer_radialGradient_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::LAYER_RADIA_GRADIENT);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
_mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
_startColorLocation = pipelineDescriptor.programState->getUniformLocation("u_startColor");
diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h
index cc77216152..38e62b61a8 100644
--- a/cocos/2d/CCLayer.h
+++ b/cocos/2d/CCLayer.h
@@ -427,7 +427,7 @@ protected:
Color3B _endColor = Color3B::BLACK;
uint8_t _startOpacity = 255;
uint8_t _endOpacity = 255;
- Vec2 _alongVector = {0, -1};
+ Vec2 _alongVector = {0.0f, -1.0f};
bool _compressedInterpolation = true;
};
diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp
index a24eddc948..fa7f129e42 100644
--- a/cocos/2d/CCMotionStreak.cpp
+++ b/cocos/2d/CCMotionStreak.cpp
@@ -42,7 +42,8 @@ MotionStreak::MotionStreak()
_customCommand.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP);
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
_mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp
index 7ecf261ffe..f203c62dc6 100644
--- a/cocos/2d/CCNode.cpp
+++ b/cocos/2d/CCNode.cpp
@@ -809,22 +809,27 @@ void Node::enumerateChildren(const std::string &name, std::functiondoEnumerateRecursive(target, newName, callback);
}
else
{
// name is xxx
- doEnumerate(newName, callback);
+ target->doEnumerate(newName, callback);
}
}
diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h
index 2f1dccd7b2..bbab0deef6 100644
--- a/cocos/2d/CCNode.h
+++ b/cocos/2d/CCNode.h
@@ -794,7 +794,7 @@ public:
* @param name The name to search for, supports c++11 regular expression.
* Search syntax options:
* `//`: Can only be placed at the begin of the search string. This indicates that it will search recursively.
- * `..`: The search should move up to the node's parent. Can only be placed at the end of string.
+ * `/..`: The search should move up to the node's parent. Can only be placed at the end of string.
* `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children.
*
* @code
diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp
index ebc58f12da..e6ab3b9ea0 100644
--- a/cocos/2d/CCParticleBatchNode.cpp
+++ b/cocos/2d/CCParticleBatchNode.cpp
@@ -29,6 +29,8 @@
*
*/
#include "2d/CCParticleBatchNode.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCGrid.h"
#include "2d/CCParticleSystem.h"
#include "renderer/CCTextureCache.h"
@@ -46,7 +48,8 @@ NS_CC_BEGIN
ParticleBatchNode::ParticleBatchNode()
{
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
_mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
diff --git a/cocos/2d/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp
index 1cda033e87..3fe170d78a 100644
--- a/cocos/2d/CCParticleExamples.cpp
+++ b/cocos/2d/CCParticleExamples.cpp
@@ -1076,7 +1076,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
// emitter position
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(winSize.width/2, winSize.height + 10);
- setPosVar(Vec2(winSize.width/2, 0));
+ setPosVar(Vec2(winSize.width/2, 0.0f));
// angle
_angle = -90;
@@ -1188,7 +1188,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
// emitter position
Size winSize = Director::getInstance()->getWinSize();
this->setPosition(winSize.width/2, winSize.height);
- setPosVar(Vec2(winSize.width/2, 0));
+ setPosVar(Vec2(winSize.width/2, 0.0f));
// life of particles
_life = 4.5f;
diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp
index 09dc7d2ff7..f69c9048d2 100644
--- a/cocos/2d/CCParticleSystemQuad.cpp
+++ b/cocos/2d/CCParticleSystemQuad.cpp
@@ -26,12 +26,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
-
#include "2d/CCParticleSystemQuad.h"
-
#include
-
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCSpriteFrame.h"
#include "2d/CCParticleBatchNode.h"
#include "renderer/CCTextureAtlas.h"
@@ -50,7 +48,8 @@ NS_CC_BEGIN
ParticleSystemQuad::ParticleSystemQuad()
{
auto& pipelieDescriptor = _quadCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelieDescriptor.programState = _programState;
_mvpMatrixLocaiton = pipelieDescriptor.programState->getUniformLocation("u_MVPMatrix");
_textureLocation = pipelieDescriptor.programState->getUniformLocation("u_texture");
diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp
index ac05931f9a..d385c3d570 100644
--- a/cocos/2d/CCProgressTimer.cpp
+++ b/cocos/2d/CCProgressTimer.cpp
@@ -25,9 +25,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "2d/CCProgressTimer.h"
-
#include
-
+#include // offsetof
+#include "base/ccTypes.h"
#include "base/ccMacros.h"
#include "base/CCDirector.h"
#include "2d/CCSprite.h"
@@ -47,7 +47,8 @@ namespace
backend::ProgramState* initPipelineDescriptor(cocos2d::CustomCommand& command, bool ridal, backend::UniformLocation &locMVP, backend::UniformLocation &locTexture)
{
auto& pipelieDescriptor = command.getPipelineDescriptor();
- auto programState = new (std::nothrow) backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ auto programState = new (std::nothrow) backend::ProgramState(program);
CC_SAFE_RELEASE(pipelieDescriptor.programState);
pipelieDescriptor.programState = programState;
diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp
index c66d1a3ddc..c7bdcf7599 100644
--- a/cocos/2d/CCRenderTexture.cpp
+++ b/cocos/2d/CCRenderTexture.cpp
@@ -196,7 +196,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, backend::PixelFormat fo
_texture2D = new (std::nothrow) Texture2D();
if (_texture2D)
{
- _texture2D->initWithBackendTexture(texture);
+ _texture2D->initWithBackendTexture(texture, CC_ENABLE_PREMULTIPLIED_ALPHA != 0);
_texture2D->setRenderTarget(true);
texture->release();
}
@@ -240,8 +240,14 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, backend::PixelFormat fo
#if defined(CC_USE_GL) || defined(CC_USE_GLES)
_sprite->setFlippedY(true);
#endif
- _sprite->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
+
+#if CC_ENABLE_PREMULTIPLIED_ALPHA != 0
+ _sprite->setBlendFunc(BlendFunc::ALPHA_PREMULTIPLIED);
_sprite->setOpacityModifyRGB(true);
+#else
+ _sprite->setBlendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED);
+ _sprite->setOpacityModifyRGB(false);
+#endif
// Disabled by default.
_autoDraw = false;
@@ -472,7 +478,7 @@ void RenderTexture::newImage(std::function imageCallback, bool fli
Image *image = new (std::nothrow) Image();
auto initCallback = [&, savedBufferWidth, savedBufferHeight, imageCallback](Image* image, const unsigned char* tempData){
- image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, true);
+ image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, _texture2D->hasPremultipliedAlpha());
imageCallback(image);
};
auto callback = std::bind(initCallback, image, std::placeholders::_1);
diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp
index 0e1f1709ab..eb20451354 100644
--- a/cocos/2d/CCSprite.cpp
+++ b/cocos/2d/CCSprite.cpp
@@ -26,9 +26,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "2d/CCSprite.h"
-
#include
-
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCSpriteBatchNode.h"
#include "2d/CCAnimationCache.h"
#include "2d/CCSpriteFrame.h"
@@ -42,6 +42,7 @@ THE SOFTWARE.
#include "platform/CCFileUtils.h"
#include "renderer/ccShaders.h"
#include "renderer/backend/ProgramState.h"
+#include "renderer/backend/Device.h"
NS_CC_BEGIN
@@ -259,10 +260,6 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
_recursiveDirty = false;
setDirty(false);
- _opacityModifyRGB = true;
-
- _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
-
_flippedX = _flippedY = false;
// default transform anchor: center
@@ -378,9 +375,11 @@ void Sprite::setVertexLayout()
void Sprite::updateShaders(const char* vert, const char* frag)
{
- auto programState = new (std::nothrow) backend::ProgramState(vert, frag);
+ auto* program = backend::Device::getInstance()->newProgram(vert, frag);
+ auto programState = new (std::nothrow) backend::ProgramState(program);
setProgramState(programState);
- CC_SAFE_RELEASE_NULL(programState);
+ CC_SAFE_RELEASE(programState);
+ CC_SAFE_RELEASE(program);
}
void Sprite::setProgramState(backend::ProgramType type)
@@ -389,7 +388,8 @@ void Sprite::setProgramState(backend::ProgramType type)
_programState->getProgram()->getProgramType() == type)
return;
- auto programState = new (std::nothrow) backend::ProgramState(type);
+ auto* program = backend::Program::getBuiltinProgram(type);
+ auto programState = new (std::nothrow) backend::ProgramState(program);
setProgramState(programState);
CC_SAFE_RELEASE_NULL(programState);
}
@@ -411,7 +411,7 @@ void Sprite::setProgramState(backend::ProgramState *programState)
_alphaTextureLocation = pipelineDescriptor.programState->getUniformLocation(backend::Uniform::TEXTURE1);
setVertexLayout();
- updateProgramState();
+ updateProgramStateTexture();
setMVPMatrixUniform();
}
@@ -419,7 +419,6 @@ void Sprite::setTexture(Texture2D *texture)
{
auto isETC1 = texture && texture->getAlphaTextureName();
setProgramState((isETC1) ? backend::ProgramType::ETC1 : backend::ProgramType::POSITION_TEXTURE_COLOR);
-
CCASSERT(! _batchNode || (texture && texture == _batchNode->getTexture()), "CCSprite: Batched sprites should use the same texture as the batchnode");
// accept texture==nil as argument
CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument");
@@ -451,11 +450,10 @@ void Sprite::setTexture(Texture2D *texture)
}
updateBlendFunc();
}
-
- updateProgramState();
+ updateProgramStateTexture();
}
-void Sprite::updateProgramState()
+void Sprite::updateProgramStateTexture()
{
if (_texture == nullptr || _texture->getBackendTexture() == nullptr)
return;
diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h
index d5f012a00a..0f0d5c14ab 100644
--- a/cocos/2d/CCSprite.h
+++ b/cocos/2d/CCSprite.h
@@ -635,7 +635,7 @@ protected:
virtual void setDirtyRecursively(bool value);
virtual void flipX();
virtual void flipY();
- virtual void updateProgramState();
+ virtual void updateProgramStateTexture();
void updatePoly();
void updateStretchFactor();
diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp
index 66174a08d5..5082f4d9b3 100644
--- a/cocos/2d/CCSpriteBatchNode.cpp
+++ b/cocos/2d/CCSpriteBatchNode.cpp
@@ -26,8 +26,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
#include "2d/CCSpriteBatchNode.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "2d/CCSprite.h"
#include "base/CCDirector.h"
#include "base/CCProfiling.h"
@@ -37,7 +38,7 @@ THE SOFTWARE.
#include "renderer/CCQuadCommand.h"
#include "renderer/ccShaders.h"
#include "renderer/backend/ProgramState.h"
-
+#include "renderer/backend/Device.h"
NS_CC_BEGIN
@@ -115,12 +116,14 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAU
void SpriteBatchNode::updateShaders(const std::string &vertexShader, const std::string &fragmentShader)
{
auto& pipelineDescriptor = _quadCommand.getPipelineDescriptor();
+ auto* program = backend::Device::getInstance()->newProgram(vertexShader, fragmentShader);
CC_SAFE_RELEASE(_programState);
- _programState = new (std::nothrow) backend::ProgramState(vertexShader, fragmentShader);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
_mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
_textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture");
-
+ CC_SAFE_RELEASE(program);
+
auto vertexLayout = _programState->getVertexLayout();
const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
auto iter = attributeInfo.find("a_position");
diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp
index a5316ae876..57bd730af0 100644
--- a/cocos/2d/CCSpriteFrameCache.cpp
+++ b/cocos/2d/CCSpriteFrameCache.cpp
@@ -384,7 +384,10 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist)
// remove .xxx
size_t startPos = texturePath.find_last_of('.');
- texturePath = texturePath.erase(startPos);
+ if(startPos != string::npos)
+ {
+ texturePath = texturePath.erase(startPos);
+ }
// append .png
texturePath = texturePath.append(".png");
@@ -686,8 +689,11 @@ bool SpriteFrameCache::reloadTexture(const std::string& plist)
// remove .xxx
size_t startPos = texturePath.find_last_of('.');
- texturePath = texturePath.erase(startPos);
-
+ if(startPos != string::npos)
+ {
+ texturePath = texturePath.erase(startPos);
+ }
+
// append .png
texturePath = texturePath.append(".png");
}
diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp
index 0fa38414cd..f4bc2ee17d 100644
--- a/cocos/2d/CCTMXLayer.cpp
+++ b/cocos/2d/CCTMXLayer.cpp
@@ -424,7 +424,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vec2& pos)
for(const auto &child : _children) {
Sprite* sp = static_cast(child);
- ssize_t ai = sp->getAtlasIndex();
+ auto ai = sp->getAtlasIndex();
if ( ai >= indexForZ )
{
sp->setAtlasIndex(ai+1);
@@ -449,8 +449,8 @@ Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vec2& pos)
setupTileSprite(tile ,pos ,gid);
// get atlas index
- ssize_t indexForZ = atlasIndexForExistantZ(z);
- tile->setAtlasIndex(indexForZ);
+ auto indexForZ = atlasIndexForExistantZ(z);
+ tile->setAtlasIndex(static_cast(indexForZ) );
tile->setDirty(true);
tile->updateTransform();
_tiles[z] = gid;
@@ -671,7 +671,7 @@ void TMXLayer::removeTileAt(const Vec2& pos)
// update possible children
for(const auto &obj : _children) {
Sprite* child = static_cast(obj);
- ssize_t ai = child->getAtlasIndex();
+ auto ai = child->getAtlasIndex();
if ( ai >= atlasIndex )
{
child->setAtlasIndex(ai-1);
diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp
index 1dcb12b749..ba3245d575 100644
--- a/cocos/2d/CCTMXXMLParser.cpp
+++ b/cocos/2d/CCTMXXMLParser.cpp
@@ -416,9 +416,9 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
{
TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back();
- double tileOffsetX = attributeDict["x"].asDouble();
+ float tileOffsetX = attributeDict["x"].asFloat();
- double tileOffsetY = attributeDict["y"].asDouble();
+ float tileOffsetY = attributeDict["y"].asFloat();
tileset->_tileOffset = Vec2(tileOffsetX, tileOffsetY);
diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp
index 50ceddd665..922b6cb547 100644
--- a/cocos/2d/CCTransition.cpp
+++ b/cocos/2d/CCTransition.cpp
@@ -360,7 +360,7 @@ void TransitionJumpZoom::onEnter()
_inScene->setAnchorPoint(Vec2(0.5f, 0.5f));
_outScene->setAnchorPoint(Vec2(0.5f, 0.5f));
- ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0), s.width/4, 2);
+ ActionInterval *jump = JumpBy::create(_duration/4, Vec2(-s.width,0.0f), s.width/4, 2);
ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f);
ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f);
@@ -425,7 +425,7 @@ void TransitionMoveInL::onEnter()
ActionInterval* TransitionMoveInL::action()
{
- return MoveTo::create(_duration, Vec2(0,0));
+ return MoveTo::create(_duration, Vec2(0.0f,0.0f));
}
ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action)
@@ -569,13 +569,13 @@ void TransitionSlideInL::sceneOrder()
void TransitionSlideInL:: initScenes()
{
Size s = Director::getInstance()->getWinSize();
- _inScene->setPosition(-(s.width-ADJUST_FACTOR),0);
+ _inScene->setPosition(-(s.width-ADJUST_FACTOR),0.0f);
}
ActionInterval* TransitionSlideInL::action()
{
Size s = Director::getInstance()->getWinSize();
- return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0));
+ return MoveBy::create(_duration, Vec2(s.width-ADJUST_FACTOR,0.0f));
}
ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action)
@@ -632,7 +632,7 @@ void TransitionSlideInR::initScenes()
ActionInterval* TransitionSlideInR:: action()
{
Size s = Director::getInstance()->getWinSize();
- return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0));
+ return MoveBy::create(_duration, Vec2(-(s.width-ADJUST_FACTOR),0.0f));
}
@@ -673,7 +673,7 @@ void TransitionSlideInT::initScenes()
ActionInterval* TransitionSlideInT::action()
{
Size s = Director::getInstance()->getWinSize();
- return MoveBy::create(_duration, Vec2(0,-(s.height-ADJUST_FACTOR)));
+ return MoveBy::create(_duration, Vec2(0.0f,-(s.height-ADJUST_FACTOR)));
}
//
@@ -713,7 +713,7 @@ void TransitionSlideInB:: initScenes()
ActionInterval* TransitionSlideInB:: action()
{
Size s = Director::getInstance()->getWinSize();
- return MoveBy::create(_duration, Vec2(0,s.height-ADJUST_FACTOR));
+ return MoveBy::create(_duration, Vec2(0.0f,s.height-ADJUST_FACTOR));
}
//
diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp
index 717113237a..25aacd7aec 100644
--- a/cocos/3d/CCBundle3D.cpp
+++ b/cocos/3d/CCBundle3D.cpp
@@ -100,7 +100,7 @@ void getChildMap(std::map >& map, SkinData* skinData, cons
const rapidjson::Value& parent_transform = val[OLDTRANSFORM];
for (rapidjson::SizeType j = 0, size = parent_transform.Size(); j < size; ++j)
{
- transform.m[j] = parent_transform[j].GetDouble();
+ transform.m[j] = parent_transform[j].GetFloat();
}
// set origin matrices
@@ -758,7 +758,7 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
meshData->vertexSizeInFloat = mesh_data_vertex_array_size;
for (rapidjson::SizeType i = 0; i < mesh_data_vertex_array_size; ++i)
{
- meshData->vertex.push_back(mesh_data_vertex_array[i].GetDouble());
+ meshData->vertex.push_back(mesh_data_vertex_array[i].GetFloat());
}
// mesh part
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -781,10 +781,10 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
const rapidjson::Value& mesh_part_aabb = mesh_part[AABBS];
if (mesh_part.HasMember(AABBS) && mesh_part_aabb.Size() == 6)
{
- Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(),
- mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble());
- Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(),
- mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble());
+ Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetFloat(),
+ mesh_part_aabb[(rapidjson::SizeType)1].GetFloat(), mesh_part_aabb[(rapidjson::SizeType)2].GetFloat());
+ Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetFloat(),
+ mesh_part_aabb[(rapidjson::SizeType)4].GetFloat(), mesh_part_aabb[(rapidjson::SizeType)5].GetFloat());
meshData->subMeshAABB.push_back(AABB(min, max));
}
else
@@ -1162,7 +1162,7 @@ bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
const rapidjson::Value& mesh_data_body_vertices = mesh_data_body_array_0[VERTICES];
for (rapidjson::SizeType i = 0; i < mesh_data_body_vertices.Size(); ++i)
- meshdata->vertex[i] = mesh_data_body_vertices[i].GetDouble();
+ meshdata->vertex[i] = mesh_data_body_vertices[i].GetFloat();
// index_number
unsigned int indexnum = mesh_data_body_array_0[INDEXNUM].GetUint();
@@ -1209,7 +1209,7 @@ bool Bundle3D::loadMeshDataJson_0_2(MeshDatas& meshdatas)
const rapidjson::Value& mesh_data_body_vertices = mesh_data_vertex_0[VERTICES];
for (rapidjson::SizeType i = 0; i < mesh_data_body_vertices.Size(); ++i)
- meshdata->vertex[i] = mesh_data_body_vertices[i].GetDouble();
+ meshdata->vertex[i] = mesh_data_body_vertices[i].GetFloat();
// submesh
const rapidjson::Value& mesh_submesh_array = mesh_array_0[SUBMESH];
@@ -1259,7 +1259,7 @@ bool Bundle3D::loadSkinDataJson(SkinData* skindata)
const rapidjson::Value& bind_pos = skin_data_bone[BINDSHAPE];
for (rapidjson::SizeType j = 0; j < bind_pos.Size(); ++j)
{
- mat_bind_pos.m[j] = bind_pos[j].GetDouble();
+ mat_bind_pos.m[j] = bind_pos[j].GetFloat();
}
skindata->inverseBindPoseMatrices.push_back(mat_bind_pos);
}
@@ -1473,7 +1473,7 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
const rapidjson::Value& animation_data_array_val_0 = animation_data_array[(rapidjson::SizeType)the_index];
- animationdata->_totalTime = animation_data_array_val_0[LENGTH].GetDouble();
+ animationdata->_totalTime = animation_data_array_val_0[LENGTH].GetFloat();
const rapidjson::Value& bones = animation_data_array_val_0[BONES];
for (rapidjson::SizeType i = 0; i < bones.Size(); ++i)
@@ -1496,24 +1496,24 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
if ( bone_keyframe.HasMember(TRANSLATION))
{
const rapidjson::Value& bone_keyframe_translation = bone_keyframe[TRANSLATION];
- float keytime = bone_keyframe[KEYTIME].GetDouble();
- Vec3 val(bone_keyframe_translation[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_translation[1].GetDouble(), bone_keyframe_translation[2].GetDouble());
+ float keytime = bone_keyframe[KEYTIME].GetFloat();
+ Vec3 val(bone_keyframe_translation[(rapidjson::SizeType)0].GetFloat(), bone_keyframe_translation[1].GetFloat(), bone_keyframe_translation[2].GetFloat());
animationdata->_translationKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val));
}
if ( bone_keyframe.HasMember(ROTATION))
{
const rapidjson::Value& bone_keyframe_rotation = bone_keyframe[ROTATION];
- float keytime = bone_keyframe[KEYTIME].GetDouble();
- Quaternion val = Quaternion(bone_keyframe_rotation[(rapidjson::SizeType)0].GetDouble(),bone_keyframe_rotation[1].GetDouble(),bone_keyframe_rotation[2].GetDouble(),bone_keyframe_rotation[3].GetDouble());
+ float keytime = bone_keyframe[KEYTIME].GetFloat();
+ Quaternion val = Quaternion(bone_keyframe_rotation[(rapidjson::SizeType)0].GetFloat(),bone_keyframe_rotation[1].GetFloat(),bone_keyframe_rotation[2].GetFloat(),bone_keyframe_rotation[3].GetFloat());
animationdata->_rotationKeys[bone_name].push_back(Animation3DData::QuatKey(keytime,val));
}
if ( bone_keyframe.HasMember(SCALE))
{
const rapidjson::Value& bone_keyframe_scale = bone_keyframe[SCALE];
- float keytime = bone_keyframe[KEYTIME].GetDouble();
- Vec3 val(bone_keyframe_scale[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_scale[1].GetDouble(), bone_keyframe_scale[2].GetDouble());
+ float keytime = bone_keyframe[KEYTIME].GetFloat();
+ Vec3 val(bone_keyframe_scale[(rapidjson::SizeType)0].GetFloat(), bone_keyframe_scale[1].GetFloat(), bone_keyframe_scale[2].GetFloat());
animationdata->_scaleKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val));
}
}
@@ -1701,7 +1701,7 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo
for (rapidjson::SizeType j = 0; j < jtransform.Size(); ++j)
{
- transform.m[j] = jtransform[j].GetDouble();
+ transform.m[j] = jtransform[j].GetFloat();
}
nodedata->transform = transform;
@@ -1753,7 +1753,7 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo
for (rapidjson::SizeType k = 0; k < jinvbindpos.Size(); ++k)
{
- invbindpos.m[k] = jinvbindpos[k].GetDouble();
+ invbindpos.m[k] = jinvbindpos[k].GetFloat();
}
//invbindpos.inverse();
diff --git a/cocos/3d/CCMotionStreak3D.cpp b/cocos/3d/CCMotionStreak3D.cpp
index b95239dbb4..6ba4da32b9 100644
--- a/cocos/3d/CCMotionStreak3D.cpp
+++ b/cocos/3d/CCMotionStreak3D.cpp
@@ -24,8 +24,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
#include "3d/CCMotionStreak3D.h"
+#include // offsetof
+#include "base/ccTypes.h"
#include "math/CCVertex.h"
#include "base/CCDirector.h"
#include "base/ccUtils.h"
@@ -118,7 +119,8 @@ bool MotionStreak3D::initWithFade(float fade, float minSeg, float stroke, const
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
// shader state
- _programState = new backend::ProgramState(positionTextureColor_vert, positionTextureColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
+ _programState = new backend::ProgramState(program);
_customCommand.getPipelineDescriptor().programState = _programState;
diff --git a/cocos/3d/CCSkybox.cpp b/cocos/3d/CCSkybox.cpp
index 019c5105dd..edb9bd2b6b 100644
--- a/cocos/3d/CCSkybox.cpp
+++ b/cocos/3d/CCSkybox.cpp
@@ -65,8 +65,8 @@ bool Skybox::init()
_customCommand.setAfterCallback(CC_CALLBACK_0(Skybox::onAfterDraw, this));
// create and set our custom shader
-
- _programState = new backend::ProgramState(CC3D_skybox_vert, CC3D_skybox_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKYBOX_3D);
+ _programState = new backend::ProgramState(program);
auto &pipelineDescriptor = _customCommand.getPipelineDescriptor();
auto layout = _programState->getVertexLayout();
diff --git a/cocos/3d/CCSprite3DMaterial.cpp b/cocos/3d/CCSprite3DMaterial.cpp
index c07922f258..561ae64e1b 100644
--- a/cocos/3d/CCSprite3DMaterial.cpp
+++ b/cocos/3d/CCSprite3DMaterial.cpp
@@ -63,80 +63,68 @@ backend::ProgramState* Sprite3DMaterial::_vertexLitMaterialSkinProgState = nullp
backend::ProgramState* Sprite3DMaterial::_diffuseMaterialSkinProgState = nullptr;
backend::ProgramState* Sprite3DMaterial::_bumpedDiffuseMaterialSkinProgState = nullptr;
-namespace
-{
- std::string getShaderMacrosForLight()
- {
- char def[256];
- auto conf = Configuration::getInstance();
-
- snprintf(def, sizeof(def)-1, "\n#define MAX_DIRECTIONAL_LIGHT_NUM %d \n"
- "\n#define MAX_POINT_LIGHT_NUM %d \n"
- "\n#define MAX_SPOT_LIGHT_NUM %d \n",
- conf->getMaxSupportDirLightInShader(),
- conf->getMaxSupportPointLightInShader(),
- conf->getMaxSupportSpotLightInShader());
-
- return std::string(def);
- }
-}
void Sprite3DMaterial::createBuiltInMaterial()
{
- std::string def = getShaderMacrosForLight();
- std::string normalMapDef = "\n#define USE_NORMAL_MAPPING 1 \n";
-
- _unLitMaterialSkinProgState = new (std::nothrow) backend::ProgramState(CC3D_skinPositionTexture_vert, CC3D_colorTexture_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_TEXTURE_3D);
+ _unLitMaterialSkinProgState = new (std::nothrow) backend::ProgramState(program);
_unLitMaterialSkin = new (std::nothrow) Sprite3DMaterial();
if (_unLitMaterialSkin && _unLitMaterialSkin->initWithProgramState(_unLitMaterialSkinProgState))
{
_unLitMaterialSkin->_type = Sprite3DMaterial::MaterialType::UNLIT;
}
- _diffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(def + CC3D_skinPositionNormalTexture_vert, def + CC3D_colorNormalTexture_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_NORMAL_TEXTURE_3D);
+ _diffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(program);
_diffuseMaterialSkin = new (std::nothrow) Sprite3DMaterial();
if (_diffuseMaterialSkin && _diffuseMaterialSkin->initWithProgramState(_diffuseMaterialSkinProgState))
{
_diffuseMaterialSkin->_type = Sprite3DMaterial::MaterialType::DIFFUSE;
}
- _diffuseMaterialProgState = new (std::nothrow) backend::ProgramState(def + CC3D_positionNormalTexture_vert, def + CC3D_colorNormalTexture_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_NORMAL_TEXTURE_3D);
+ _diffuseMaterialProgState = new (std::nothrow) backend::ProgramState(program);
_diffuseMaterial = new (std::nothrow) Sprite3DMaterial();
if (_diffuseMaterial && _diffuseMaterial->initWithProgramState(_diffuseMaterialProgState))
{
_diffuseMaterial->_type = Sprite3DMaterial::MaterialType::DIFFUSE;
}
- _unLitMaterialProgState = new (std::nothrow) backend::ProgramState(CC3D_positionTexture_vert, CC3D_colorTexture_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_3D);
+ _unLitMaterialProgState = new (std::nothrow) backend::ProgramState(program);
_unLitMaterial = new (std::nothrow) Sprite3DMaterial();
if (_unLitMaterial && _unLitMaterial->initWithProgramState(_unLitMaterialProgState))
{
_unLitMaterial->_type = Sprite3DMaterial::MaterialType::UNLIT;
}
- _unLitNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(CC3D_positionTexture_vert, CC3D_color_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_3D);
+ _unLitNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(program);
_unLitNoTexMaterial = new (std::nothrow) Sprite3DMaterial();
if (_unLitNoTexMaterial && _unLitNoTexMaterial->initWithProgramState(_unLitNoTexMaterialProgState))
{
_unLitNoTexMaterial->_type = Sprite3DMaterial::MaterialType::UNLIT_NOTEX;
}
- _diffuseNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(def + CC3D_positionNormalTexture_vert, def + CC3D_colorNormal_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_NORMAL_3D);
+ _diffuseNoTexMaterialProgState = new (std::nothrow) backend::ProgramState(program);
_diffuseNoTexMaterial = new (std::nothrow) Sprite3DMaterial();
if (_diffuseNoTexMaterial && _diffuseNoTexMaterial->initWithProgramState(_diffuseNoTexMaterialProgState))
{
_diffuseNoTexMaterial->_type = Sprite3DMaterial::MaterialType::DIFFUSE_NOTEX;
}
- _bumpedDiffuseMaterialProgState = new (std::nothrow) backend::ProgramState(def + normalMapDef + CC3D_positionNormalTexture_vert, def + normalMapDef + CC3D_colorNormalTexture_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_BUMPEDNORMAL_TEXTURE_3D);
+ _bumpedDiffuseMaterialProgState = new (std::nothrow) backend::ProgramState(program);
_bumpedDiffuseMaterial = new (std::nothrow) Sprite3DMaterial();
if (_bumpedDiffuseMaterial && _bumpedDiffuseMaterial->initWithProgramState(_bumpedDiffuseMaterialProgState))
{
_bumpedDiffuseMaterial->_type = Sprite3DMaterial::MaterialType::BUMPED_DIFFUSE;
}
- _bumpedDiffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(def + normalMapDef + CC3D_skinPositionNormalTexture_vert, def + normalMapDef + CC3D_colorNormalTexture_frag);
+ program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D);
+ _bumpedDiffuseMaterialSkinProgState = new (std::nothrow) backend::ProgramState(program);
_bumpedDiffuseMaterialSkin = new (std::nothrow) Sprite3DMaterial();
if (_bumpedDiffuseMaterialSkin && _bumpedDiffuseMaterialSkin->initWithProgramState(_bumpedDiffuseMaterialSkinProgState))
{
diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp
index 343341267e..c31d486830 100644
--- a/cocos/3d/CCTerrain.cpp
+++ b/cocos/3d/CCTerrain.cpp
@@ -29,12 +29,14 @@ USING_NS_CC;
#include
#include
#include
+#include // offsetof
#include "renderer/CCRenderer.h"
#include "renderer/ccShaders.h"
#include "renderer/backend/Device.h"
#include "renderer/backend/Program.h"
#include "renderer/backend/Buffer.h"
#include "base/CCDirector.h"
+#include "base/ccTypes.h"
#include "base/CCEventType.h"
#include "2d/CCCamera.h"
#include "platform/CCImage.h"
@@ -115,7 +117,8 @@ void cocos2d::Terrain::setLightDir(const Vec3& lightDir)
bool Terrain::initProperties()
{
- _programState = new backend::ProgramState(CC3D_terrain_vert, CC3D_terrain_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::TERRAIN_3D);
+ _programState = new backend::ProgramState(program);
_stateBlock.depthWrite = true;
_stateBlock.depthTest = true;
@@ -1402,8 +1405,6 @@ void Terrain::Chunk::updateVerticesForLOD()
}
}
- //TODO coulsonwang
-// glBufferData(GL_ARRAY_BUFFER, sizeof(TerrainVertexData)*_currentVertices.size(), &_currentVertices[0], GL_STREAM_DRAW);
_oldLod = _currentLod;
}
diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt
index c2f0edd638..50349bfbd0 100644
--- a/cocos/CMakeLists.txt
+++ b/cocos/CMakeLists.txt
@@ -152,3 +152,9 @@ if(WINDOWS)
# compile c as c++. needed for precompiled header
set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX)
endif()
+
+#if(XCODE)
+# # Later versions of Xcode clang want to compile C++17 with aligned allocation turned on and this is only supported on iOS 11.0+
+# # TODO: Only turn this off if ${CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET} < 11.0
+# target_compile_options(cocos2d PUBLIC $<$:-fno-aligned-allocation>)
+#endif()
diff --git a/cocos/audio/AudioEngine.cpp b/cocos/audio/AudioEngine.cpp
index 3f192341f0..9035daed66 100644
--- a/cocos/audio/AudioEngine.cpp
+++ b/cocos/audio/AudioEngine.cpp
@@ -48,7 +48,6 @@
#endif // ERROR
using namespace cocos2d;
-using namespace cocos2d::experimental;
const int AudioEngine::INVALID_AUDIO_ID = -1;
const float AudioEngine::TIME_UNKNOWN = -1.0f;
diff --git a/cocos/audio/android/AssetFd.cpp b/cocos/audio/android/AssetFd.cpp
index fc8303142f..9d6e6a051a 100644
--- a/cocos/audio/android/AssetFd.cpp
+++ b/cocos/audio/android/AssetFd.cpp
@@ -28,7 +28,7 @@ THE SOFTWARE.
#include "audio/android/cutils/log.h"
#include "audio/android/AssetFd.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AssetFd::AssetFd(int assetFd)
: _assetFd(assetFd)
@@ -45,4 +45,4 @@ AssetFd::~AssetFd()
}
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AssetFd.h b/cocos/audio/android/AssetFd.h
index aedb8c8ac2..d380f694d0 100644
--- a/cocos/audio/android/AssetFd.h
+++ b/cocos/audio/android/AssetFd.h
@@ -26,7 +26,7 @@ THE SOFTWARE.
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AssetFd
{
@@ -39,5 +39,5 @@ private:
int _assetFd;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioBufferProvider.h b/cocos/audio/android/AudioBufferProvider.h
index cf9a3c0974..8efeea6da9 100644
--- a/cocos/audio/android/AudioBufferProvider.h
+++ b/cocos/audio/android/AudioBufferProvider.h
@@ -20,7 +20,7 @@
#include
#include "audio/android/utils/Errors.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// ----------------------------------------------------------------------------
class AudioBufferProvider
@@ -77,4 +77,4 @@ public:
};
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioDecoder.cpp b/cocos/audio/android/AudioDecoder.cpp
index 5f14e83fd5..78327e490c 100644
--- a/cocos/audio/android/AudioDecoder.cpp
+++ b/cocos/audio/android/AudioDecoder.cpp
@@ -34,7 +34,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
size_t AudioDecoder::fileRead(void* ptr, size_t size, size_t nmemb, void* datasource)
{
@@ -291,4 +291,4 @@ bool AudioDecoder::interleave()
return false;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioDecoder.h b/cocos/audio/android/AudioDecoder.h
index 46ad515b1f..8ad1f2b4cf 100644
--- a/cocos/audio/android/AudioDecoder.h
+++ b/cocos/audio/android/AudioDecoder.h
@@ -29,7 +29,7 @@ THE SOFTWARE.
#include "audio/android/PcmData.h"
#include "base/CCData.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoder
{
@@ -61,4 +61,4 @@ protected:
size_t _fileCurrPos;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioDecoderMp3.cpp b/cocos/audio/android/AudioDecoderMp3.cpp
index 136c562fa7..a5ea481982 100644
--- a/cocos/audio/android/AudioDecoderMp3.cpp
+++ b/cocos/audio/android/AudioDecoderMp3.cpp
@@ -29,7 +29,7 @@ THE SOFTWARE.
#include "audio/android/mp3reader.h"
#include "platform/CCFileUtils.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoderMp3::AudioDecoderMp3()
{
@@ -80,4 +80,4 @@ bool AudioDecoderMp3::decodeToPcm()
return false;
}
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderMp3.h b/cocos/audio/android/AudioDecoderMp3.h
index 3def5a202d..8531320afe 100644
--- a/cocos/audio/android/AudioDecoderMp3.h
+++ b/cocos/audio/android/AudioDecoderMp3.h
@@ -27,7 +27,7 @@ THE SOFTWARE.
#include "audio/android/AudioDecoder.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoderMp3 : public AudioDecoder
{
@@ -40,4 +40,4 @@ protected:
friend class AudioDecoderProvider;
};
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderOgg.cpp b/cocos/audio/android/AudioDecoderOgg.cpp
index 15f033636b..a1efb56f28 100644
--- a/cocos/audio/android/AudioDecoderOgg.cpp
+++ b/cocos/audio/android/AudioDecoderOgg.cpp
@@ -28,7 +28,7 @@ THE SOFTWARE.
#include "audio/android/AudioDecoderOgg.h"
#include "platform/CCFileUtils.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoderOgg::AudioDecoderOgg()
{
@@ -110,4 +110,4 @@ bool AudioDecoderOgg::decodeToPcm()
return (curPos > 0);
}
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderOgg.h b/cocos/audio/android/AudioDecoderOgg.h
index 4ad5166e65..e9eb6dfaee 100644
--- a/cocos/audio/android/AudioDecoderOgg.h
+++ b/cocos/audio/android/AudioDecoderOgg.h
@@ -29,7 +29,7 @@ THE SOFTWARE.
#include "Tremolo/ivorbisfile.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoderOgg : public AudioDecoder
{
@@ -43,4 +43,4 @@ protected:
friend class AudioDecoderProvider;
};
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderProvider.cpp b/cocos/audio/android/AudioDecoderProvider.cpp
index cedf52b20e..077d8136bd 100644
--- a/cocos/audio/android/AudioDecoderProvider.cpp
+++ b/cocos/audio/android/AudioDecoderProvider.cpp
@@ -31,7 +31,7 @@
#include "audio/android/AudioDecoderWav.h"
#include "platform/CCFileUtils.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoder* AudioDecoderProvider::createAudioDecoder(SLEngineItf engineItf, const std::string &url, int bufferSizeInFrames, int sampleRate, const FdGetterCallback &fdGetterCallback)
{
@@ -90,4 +90,4 @@ void AudioDecoderProvider::destroyAudioDecoder(AudioDecoder** decoder)
}
}
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderProvider.h b/cocos/audio/android/AudioDecoderProvider.h
index 9b2e7e1cb4..8070af0e0e 100644
--- a/cocos/audio/android/AudioDecoderProvider.h
+++ b/cocos/audio/android/AudioDecoderProvider.h
@@ -27,7 +27,7 @@ THE SOFTWARE.
#include "audio/android/OpenSLHelper.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoder;
@@ -38,4 +38,4 @@ public:
static void destroyAudioDecoder(AudioDecoder** decoder);
};
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderSLES.cpp b/cocos/audio/android/AudioDecoderSLES.cpp
index bbcc9382b2..837126305b 100644
--- a/cocos/audio/android/AudioDecoderSLES.cpp
+++ b/cocos/audio/android/AudioDecoderSLES.cpp
@@ -28,7 +28,7 @@ THE SOFTWARE.
#include "audio/android/AudioDecoderSLES.h"
#include "platform/CCFileUtils.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/* Explicitly requesting SL_IID_ANDROIDSIMPLEBUFFERQUEUE and SL_IID_PREFETCHSTATUS
* on the UrlAudioPlayer object for decoding, SL_IID_METADATAEXTRACTION for retrieving the
@@ -643,4 +643,4 @@ void AudioDecoderSLES::decodeToPcmCallback(SLAndroidSimpleBufferQueueItf queueIt
queryAudioInfo();
}
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderSLES.h b/cocos/audio/android/AudioDecoderSLES.h
index 30795ab736..4055b8e5a1 100644
--- a/cocos/audio/android/AudioDecoderSLES.h
+++ b/cocos/audio/android/AudioDecoderSLES.h
@@ -29,7 +29,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoderSLES : public AudioDecoder
{
@@ -94,4 +94,4 @@ private:
friend class AudioDecoderProvider;
};
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderWav.cpp b/cocos/audio/android/AudioDecoderWav.cpp
index a89526ced1..b55dc0dd8c 100644
--- a/cocos/audio/android/AudioDecoderWav.cpp
+++ b/cocos/audio/android/AudioDecoderWav.cpp
@@ -29,7 +29,7 @@ THE SOFTWARE.
#include "audio/android/tinysndfile.h"
#include "platform/CCFileUtils.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoderWav::AudioDecoderWav()
{
@@ -110,4 +110,4 @@ bool AudioDecoderWav::decodeToPcm()
return ret;
}
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioDecoderWav.h b/cocos/audio/android/AudioDecoderWav.h
index 41d57e6bf0..4234f04c90 100644
--- a/cocos/audio/android/AudioDecoderWav.h
+++ b/cocos/audio/android/AudioDecoderWav.h
@@ -27,7 +27,7 @@ THE SOFTWARE.
#include "audio/android/AudioDecoder.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoderWav : public AudioDecoder
{
@@ -44,4 +44,4 @@ protected:
friend class AudioDecoderProvider;
};
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/AudioEngine-inl.cpp b/cocos/audio/android/AudioEngine-inl.cpp
index 81bd20f335..09bcd63f02 100644
--- a/cocos/audio/android/AudioEngine-inl.cpp
+++ b/cocos/audio/android/AudioEngine-inl.cpp
@@ -55,7 +55,6 @@
#include "audio/android/UrlAudioPlayer.h"
using namespace cocos2d;
-using namespace cocos2d::experimental;
// Audio focus values synchronized with which in cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java
static const int AUDIOFOCUS_GAIN = 0;
diff --git a/cocos/audio/android/AudioEngine-inl.h b/cocos/audio/android/AudioEngine-inl.h
index 9b68d43d25..cef13de5d4 100644
--- a/cocos/audio/android/AudioEngine-inl.h
+++ b/cocos/audio/android/AudioEngine-inl.h
@@ -43,8 +43,6 @@ NS_CC_BEGIN
class EventCustom;
class EventListener;
-namespace experimental {
-
class IAudioPlayer;
class AudioPlayerProvider;
@@ -103,7 +101,7 @@ private:
};
#endif // __AUDIO_ENGINE_INL_H_
- }
+
NS_CC_END
#endif
diff --git a/cocos/audio/android/AudioMixer.cpp b/cocos/audio/android/AudioMixer.cpp
index 2b9e1baacf..cfd665a464 100644
--- a/cocos/audio/android/AudioMixer.cpp
+++ b/cocos/audio/android/AudioMixer.cpp
@@ -73,7 +73,7 @@ static const bool kUseFloat = false;
// Set to default copy buffer size in frames for input processing.
static const size_t kCopyBufferFrameCount = 256;
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// ----------------------------------------------------------------------------
@@ -2098,4 +2098,4 @@ AudioMixer::process_hook_t AudioMixer::getProcessHook(int processType, uint32_t
}
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioMixer.h b/cocos/audio/android/AudioMixer.h
index dc2080d71f..dd90ab40a1 100644
--- a/cocos/audio/android/AudioMixer.h
+++ b/cocos/audio/android/AudioMixer.h
@@ -30,7 +30,7 @@
// FIXME This is actually unity gain, which might not be max in future, expressed in U.12
#define MAX_GAIN_INT AudioMixer::UNITY_GAIN_INT
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// ----------------------------------------------------------------------------
@@ -386,4 +386,4 @@ private:
};
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioMixerController.cpp b/cocos/audio/android/AudioMixerController.cpp
index 4ffb323c09..4a92029600 100644
--- a/cocos/audio/android/AudioMixerController.cpp
+++ b/cocos/audio/android/AudioMixerController.cpp
@@ -33,7 +33,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioMixerController::AudioMixerController(int bufferSizeInFrames, int sampleRate, int channelCount)
: _bufferSizeInFrames(bufferSizeInFrames)
@@ -348,4 +348,4 @@ bool AudioMixerController::hasPlayingTacks()
return false;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioMixerController.h b/cocos/audio/android/AudioMixerController.h
index ce2097010f..d8c08f3fbc 100644
--- a/cocos/audio/android/AudioMixerController.h
+++ b/cocos/audio/android/AudioMixerController.h
@@ -33,7 +33,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class Track;
class AudioMixer;
@@ -85,4 +85,4 @@ private:
std::atomic_bool _isMixingFrame;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioMixerOps.h b/cocos/audio/android/AudioMixerOps.h
index 1e74daeb26..4a37aabaaa 100644
--- a/cocos/audio/android/AudioMixerOps.h
+++ b/cocos/audio/android/AudioMixerOps.h
@@ -18,7 +18,7 @@
#include "audio/android/cutils/log.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/* Behavior of is_same<>::value is true if the types are identical,
* false otherwise. Identical to the STL std::is_same.
@@ -446,5 +446,5 @@ inline void volumeMulti(TO* out, size_t frameCount,
}
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioPlayerProvider.cpp b/cocos/audio/android/AudioPlayerProvider.cpp
index e42506482f..12c55659c7 100644
--- a/cocos/audio/android/AudioPlayerProvider.cpp
+++ b/cocos/audio/android/AudioPlayerProvider.cpp
@@ -40,7 +40,7 @@ THE SOFTWARE.
#include
#include // for std::find_if
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
static int getSystemAPILevel()
{
@@ -516,4 +516,4 @@ void AudioPlayerProvider::resume()
}
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioPlayerProvider.h b/cocos/audio/android/AudioPlayerProvider.h
index 8b21984c30..3f72a39f1d 100644
--- a/cocos/audio/android/AudioPlayerProvider.h
+++ b/cocos/audio/android/AudioPlayerProvider.h
@@ -33,7 +33,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// Manage PcmAudioPlayer& UrlAudioPlayer
class PcmAudioPlayer;
@@ -124,5 +124,5 @@ private:
ThreadPool* _threadPool;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioResampler.cpp b/cocos/audio/android/AudioResampler.cpp
index ab12289360..134821b964 100644
--- a/cocos/audio/android/AudioResampler.cpp
+++ b/cocos/audio/android/AudioResampler.cpp
@@ -39,7 +39,7 @@
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// ----------------------------------------------------------------------------
@@ -785,4 +785,4 @@ void AudioResamplerOrder1::AsmStereo16Loop(int16_t *in, int32_t* maxOutPt, int32
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioResampler.h b/cocos/audio/android/AudioResampler.h
index ee9185bb52..1e2a6ab23f 100644
--- a/cocos/audio/android/AudioResampler.h
+++ b/cocos/audio/android/AudioResampler.h
@@ -31,7 +31,7 @@
#include
#include "audio/android/audio.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioResampler {
@@ -178,4 +178,4 @@ private:
};
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioResamplerCubic.cpp b/cocos/audio/android/AudioResamplerCubic.cpp
index 2b85321245..c2cbf13019 100644
--- a/cocos/audio/android/AudioResamplerCubic.cpp
+++ b/cocos/audio/android/AudioResamplerCubic.cpp
@@ -24,7 +24,7 @@
#include "audio/android/AudioResampler.h"
#include "audio/android/AudioResamplerCubic.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// ----------------------------------------------------------------------------
void AudioResamplerCubic::init() {
@@ -188,4 +188,4 @@ save_state:
}
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioResamplerCubic.h b/cocos/audio/android/AudioResamplerCubic.h
index ef71b771f3..ab7145f1ff 100644
--- a/cocos/audio/android/AudioResamplerCubic.h
+++ b/cocos/audio/android/AudioResamplerCubic.h
@@ -22,7 +22,7 @@
#include "audio/android/AudioResampler.h"
#include "audio/android/AudioBufferProvider.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// ----------------------------------------------------------------------------
class AudioResamplerCubic : public AudioResampler {
@@ -62,4 +62,4 @@ private:
};
// ----------------------------------------------------------------------------
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/AudioResamplerPublic.h b/cocos/audio/android/AudioResamplerPublic.h
index 68f31ba60e..cb6e05bfb2 100644
--- a/cocos/audio/android/AudioResamplerPublic.h
+++ b/cocos/audio/android/AudioResamplerPublic.h
@@ -19,7 +19,7 @@
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// AUDIO_RESAMPLER_DOWN_RATIO_MAX is the maximum ratio between the original
// audio sample rate and the target rate when downsampling,
@@ -169,6 +169,6 @@ static inline bool isMusicRate(uint32_t sampleRate) {
return sampleRate >= AUDIO_PROCESSING_MUSIC_RATE;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
// ---------------------------------------------------------------------------
diff --git a/cocos/audio/android/CCThreadPool.cpp b/cocos/audio/android/CCThreadPool.cpp
index bc9213dfe9..9cdc6747b1 100644
--- a/cocos/audio/android/CCThreadPool.cpp
+++ b/cocos/audio/android/CCThreadPool.cpp
@@ -38,7 +38,7 @@
#define LOGD(...) printf(__VA_ARGS__)
#endif
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
#define DEFAULT_THREAD_POOL_MIN_NUM (4)
#define DEFAULT_THREAD_POOL_MAX_NUM (20)
@@ -440,4 +440,4 @@ void ThreadPool::setThread(int tid)
new(std::nothrow) std::thread(f)); // compiler may not support std::make_unique()
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/CCThreadPool.h b/cocos/audio/android/CCThreadPool.h
index 6f20dc2833..b7783b4eb4 100644
--- a/cocos/audio/android/CCThreadPool.h
+++ b/cocos/audio/android/CCThreadPool.h
@@ -38,7 +38,7 @@
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/**
* @addtogroup base
@@ -234,4 +234,4 @@ private:
// end of base group
/// @}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/IAudioPlayer.h b/cocos/audio/android/IAudioPlayer.h
index c1e58c0203..61eefd523f 100644
--- a/cocos/audio/android/IAudioPlayer.h
+++ b/cocos/audio/android/IAudioPlayer.h
@@ -27,7 +27,7 @@ THE SOFTWARE.
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class IAudioPlayer
{
@@ -86,4 +86,4 @@ public:
virtual void setPlayEventCallback(const PlayEventCallback &playEventCallback) = 0;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/ICallerThreadUtils.h b/cocos/audio/android/ICallerThreadUtils.h
index 54ac681799..8363334d49 100644
--- a/cocos/audio/android/ICallerThreadUtils.h
+++ b/cocos/audio/android/ICallerThreadUtils.h
@@ -27,7 +27,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class ICallerThreadUtils
{
@@ -39,4 +39,4 @@ public:
virtual std::thread::id getCallerThreadId() = 0;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/IVolumeProvider.h b/cocos/audio/android/IVolumeProvider.h
index 076ac65b26..5aeb7c26de 100644
--- a/cocos/audio/android/IVolumeProvider.h
+++ b/cocos/audio/android/IVolumeProvider.h
@@ -26,7 +26,7 @@ THE SOFTWARE.
#include "audio/android/audio_utils/include/audio_utils/minifloat.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class IVolumeProvider
{
@@ -42,4 +42,4 @@ protected:
{ }
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmAudioPlayer.cpp b/cocos/audio/android/PcmAudioPlayer.cpp
index 2fbba41b0d..ab888809c5 100644
--- a/cocos/audio/android/PcmAudioPlayer.cpp
+++ b/cocos/audio/android/PcmAudioPlayer.cpp
@@ -30,7 +30,7 @@ THE SOFTWARE.
#include "audio/android/AudioMixerController.h"
#include "audio/android/ICallerThreadUtils.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
PcmAudioPlayer::PcmAudioPlayer(AudioMixerController * controller, ICallerThreadUtils* callerThreadUtils)
: _id(-1)
@@ -223,4 +223,4 @@ IAudioPlayer::State PcmAudioPlayer::getState() const
return state;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmAudioPlayer.h b/cocos/audio/android/PcmAudioPlayer.h
index aaacefc5a0..4959877dbc 100644
--- a/cocos/audio/android/PcmAudioPlayer.h
+++ b/cocos/audio/android/PcmAudioPlayer.h
@@ -29,7 +29,7 @@ THE SOFTWARE.
#include "audio/android/PcmData.h"
#include "audio/android/Track.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class ICallerThreadUtils;
class AudioMixerController;
@@ -95,4 +95,4 @@ private:
friend class AudioPlayerProvider;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmAudioService.cpp b/cocos/audio/android/PcmAudioService.cpp
index e6aa23c848..70950e4fa8 100644
--- a/cocos/audio/android/PcmAudioService.cpp
+++ b/cocos/audio/android/PcmAudioService.cpp
@@ -28,7 +28,7 @@ THE SOFTWARE.
#include "audio/android/PcmAudioService.h"
#include "audio/android/AudioMixerController.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
static std::vector __silenceData;
@@ -197,4 +197,4 @@ void PcmAudioService::resume()
}
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmAudioService.h b/cocos/audio/android/PcmAudioService.h
index 27559f2c7f..cebb82f832 100644
--- a/cocos/audio/android/PcmAudioService.h
+++ b/cocos/audio/android/PcmAudioService.h
@@ -32,7 +32,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioMixerController;
@@ -79,4 +79,4 @@ private:
friend class AudioPlayerProvider;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmBufferProvider.cpp b/cocos/audio/android/PcmBufferProvider.cpp
index 4ed2011c1a..82ca9b6293 100644
--- a/cocos/audio/android/PcmBufferProvider.cpp
+++ b/cocos/audio/android/PcmBufferProvider.cpp
@@ -35,7 +35,7 @@ THE SOFTWARE.
#define ALOGVV(a...) do { } while (0)
#endif
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
PcmBufferProvider::PcmBufferProvider()
: _addr(nullptr)
@@ -99,4 +99,4 @@ void PcmBufferProvider::reset() {
_nextFrame = 0;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmBufferProvider.h b/cocos/audio/android/PcmBufferProvider.h
index e5f5a2a7d5..253d9e9edb 100644
--- a/cocos/audio/android/PcmBufferProvider.h
+++ b/cocos/audio/android/PcmBufferProvider.h
@@ -30,7 +30,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class PcmBufferProvider : public AudioBufferProvider
{
@@ -49,4 +49,4 @@ protected:
size_t _unrel; // number of frames not yet released
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmData.cpp b/cocos/audio/android/PcmData.cpp
index a3bd8ddaa3..240aae8721 100644
--- a/cocos/audio/android/PcmData.cpp
+++ b/cocos/audio/android/PcmData.cpp
@@ -28,7 +28,7 @@ THE SOFTWARE.
#include "audio/android/OpenSLHelper.h"
#include "audio/android/PcmData.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
PcmData::PcmData()
{
@@ -136,4 +136,4 @@ std::string PcmData::toString() const
return ret;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/PcmData.h b/cocos/audio/android/PcmData.h
index d0445e0cc0..18cf5cc162 100644
--- a/cocos/audio/android/PcmData.h
+++ b/cocos/audio/android/PcmData.h
@@ -30,7 +30,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
struct PcmData
{
@@ -63,4 +63,4 @@ struct PcmData
std::string toString() const;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/Track.cpp b/cocos/audio/android/Track.cpp
index d2f7c9be4d..f93fcaedbc 100644
--- a/cocos/audio/android/Track.cpp
+++ b/cocos/audio/android/Track.cpp
@@ -30,7 +30,7 @@ THE SOFTWARE.
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
Track::Track(const PcmData &pcmData)
: onStateChanged(nullptr)
@@ -103,4 +103,4 @@ void Track::setState(State state)
}
};
-}} // namespace cocos2d { namespace experimental {
\ No newline at end of file
+} // namespace cocos2d {
\ No newline at end of file
diff --git a/cocos/audio/android/Track.h b/cocos/audio/android/Track.h
index 09b8e2eb2f..cec7588011 100644
--- a/cocos/audio/android/Track.h
+++ b/cocos/audio/android/Track.h
@@ -32,7 +32,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class Track : public PcmBufferProvider, public IVolumeProvider
{
@@ -104,4 +104,4 @@ private:
friend class AudioMixerController;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/UrlAudioPlayer.cpp b/cocos/audio/android/UrlAudioPlayer.cpp
index ef073691c5..b05b0f45c4 100644
--- a/cocos/audio/android/UrlAudioPlayer.cpp
+++ b/cocos/audio/android/UrlAudioPlayer.cpp
@@ -34,12 +34,12 @@ THE SOFTWARE.
namespace {
std::mutex __playerContainerMutex;
-std::vector __playerContainer;
+std::vector __playerContainer;
std::once_flag __onceFlag;
}
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class SLUrlAudioPlayerCallbackProxy
{
@@ -421,4 +421,4 @@ void UrlAudioPlayer::destroy()
}
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/UrlAudioPlayer.h b/cocos/audio/android/UrlAudioPlayer.h
index 16885effa8..22b4f4e28e 100644
--- a/cocos/audio/android/UrlAudioPlayer.h
+++ b/cocos/audio/android/UrlAudioPlayer.h
@@ -33,7 +33,7 @@ THE SOFTWARE.
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class ICallerThreadUtils;
class AssetFd;
@@ -132,4 +132,4 @@ private:
friend class AudioPlayerProvider;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/android/utils/Errors.h b/cocos/audio/android/utils/Errors.h
index a305cf5205..da8c7e6e47 100644
--- a/cocos/audio/android/utils/Errors.h
+++ b/cocos/audio/android/utils/Errors.h
@@ -20,7 +20,7 @@
#include
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
// use this type to return error codes
#ifdef _WIN32
@@ -81,7 +81,7 @@ enum {
# define NO_ERROR 0L
#endif
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
// ---------------------------------------------------------------------------
diff --git a/cocos/audio/android/utils/Utils.cpp b/cocos/audio/android/utils/Utils.cpp
index bbd60ace04..7a40ae2d4c 100644
--- a/cocos/audio/android/utils/Utils.cpp
+++ b/cocos/audio/android/utils/Utils.cpp
@@ -25,11 +25,11 @@ THE SOFTWARE.
#include "audio/android/utils/Utils.h"
#include "platform/android/jni/JniHelper.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
int getSDKVersion()
{
return JniHelper::callStaticIntMethod("org.cocos2dx.lib.Cocos2dxHelper", "getSDKVersion");
}
-}} // end of namespace cocos2d { namespace experimental
+} // end of namespace cocos2d
diff --git a/cocos/audio/android/utils/Utils.h b/cocos/audio/android/utils/Utils.h
index 90ae035a4d..b48558bc1e 100644
--- a/cocos/audio/android/utils/Utils.h
+++ b/cocos/audio/android/utils/Utils.h
@@ -25,6 +25,6 @@ THE SOFTWARE.
#include
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
extern int getSDKVersion();
-}}
+}
diff --git a/cocos/audio/apple/AudioCache.h b/cocos/audio/apple/AudioCache.h
index 6174dcbdef..3052e8ba57 100644
--- a/cocos/audio/apple/AudioCache.h
+++ b/cocos/audio/apple/AudioCache.h
@@ -25,9 +25,6 @@
#pragma once
-#include "platform/CCPlatformConfig.h"
-#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
-
#import
#include
@@ -38,7 +35,6 @@
#include "audio/apple/AudioMacros.h"
NS_CC_BEGIN
-namespace experimental{
class AudioEngineImpl;
class AudioPlayer;
@@ -111,6 +107,3 @@ protected:
};
}
-NS_CC_END
-
-#endif
diff --git a/cocos/audio/apple/AudioCache.mm b/cocos/audio/apple/AudioCache.mm
index 901c9a1b0f..fac5a1b091 100644
--- a/cocos/audio/apple/AudioCache.mm
+++ b/cocos/audio/apple/AudioCache.mm
@@ -25,9 +25,6 @@
#define LOG_TAG "AudioCache"
-#include "platform/CCPlatformConfig.h"
-#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
-
#include "audio/apple/AudioCache.h"
#import
@@ -89,7 +86,6 @@ unsigned int __idIndex = 0;
@end
using namespace cocos2d;
-using namespace cocos2d::experimental;
AudioCache::AudioCache()
: _format(-1)
@@ -405,5 +401,3 @@ void AudioCache::invokingLoadCallbacks()
_loadCallbacks.clear();
});
}
-
-#endif
diff --git a/cocos/audio/apple/AudioDecoder.h b/cocos/audio/apple/AudioDecoder.h
index 42fcf5e2ca..1739bbb629 100644
--- a/cocos/audio/apple/AudioDecoder.h
+++ b/cocos/audio/apple/AudioDecoder.h
@@ -28,7 +28,7 @@
#include
#import
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/**
* @brief The class for decoding compressed audio file to PCM buffer.
@@ -117,4 +117,4 @@ private:
AudioStreamBasicDescription _outputFormat;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/apple/AudioDecoder.mm b/cocos/audio/apple/AudioDecoder.mm
index 5fc2bc3438..96e495e935 100644
--- a/cocos/audio/apple/AudioDecoder.mm
+++ b/cocos/audio/apple/AudioDecoder.mm
@@ -30,7 +30,7 @@
#define LOG_TAG "AudioDecoder"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoder::AudioDecoder()
: _isOpened(false)
@@ -226,4 +226,4 @@ namespace cocos2d { namespace experimental {
return _isOpened;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/apple/AudioEngine-inl.h b/cocos/audio/apple/AudioEngine-inl.h
index 4176b6df09..31e5b69cdc 100644
--- a/cocos/audio/apple/AudioEngine-inl.h
+++ b/cocos/audio/apple/AudioEngine-inl.h
@@ -22,12 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
-#include "platform/CCPlatformConfig.h"
-#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
-
-#ifndef __AUDIO_ENGINE_INL_H_
-#define __AUDIO_ENGINE_INL_H_
+#pragma once
#include
#include
@@ -39,7 +34,6 @@
NS_CC_BEGIN
class Scheduler;
-namespace experimental{
#define MAX_AUDIOINSTANCES 24
class AudioEngineImpl : public cocos2d::Ref
@@ -89,7 +83,4 @@ private:
int _currentAudioID;
Scheduler* _scheduler;
};
-}
NS_CC_END
-#endif // __AUDIO_ENGINE_INL_H_
-#endif
diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm
index 81b8b86a89..64cf02bb86 100644
--- a/cocos/audio/apple/AudioEngine-inl.mm
+++ b/cocos/audio/apple/AudioEngine-inl.mm
@@ -25,9 +25,6 @@
#define LOG_TAG "AudioEngine-inl.mm"
-#include "platform/CCPlatformConfig.h"
-#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
-
#include "audio/apple/AudioEngine-inl.h"
#import
@@ -44,7 +41,6 @@
#endif
using namespace cocos2d;
-using namespace cocos2d::experimental;
static ALCdevice* s_ALDevice = nullptr;
static ALCcontext* s_ALContext = nullptr;
@@ -711,5 +707,3 @@ void AudioEngineImpl::uncacheAll()
{
_audioCaches.clear();
}
-
-#endif
diff --git a/cocos/audio/apple/AudioPlayer.h b/cocos/audio/apple/AudioPlayer.h
index db4c9a08aa..b88cf3fe9b 100644
--- a/cocos/audio/apple/AudioPlayer.h
+++ b/cocos/audio/apple/AudioPlayer.h
@@ -25,9 +25,6 @@
#pragma once
-#include "platform/CCPlatformConfig.h"
-#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
-
#include "platform/CCPlatformMacros.h"
#include "audio/apple/AudioMacros.h"
@@ -38,7 +35,6 @@
#include
NS_CC_BEGIN
-namespace experimental{
class AudioCache;
class AudioEngineImpl;
@@ -91,7 +87,4 @@ protected:
friend class AudioEngineImpl;
};
-}
NS_CC_END
-
-#endif
diff --git a/cocos/audio/apple/AudioPlayer.mm b/cocos/audio/apple/AudioPlayer.mm
index 4f5455c554..cd97915a56 100644
--- a/cocos/audio/apple/AudioPlayer.mm
+++ b/cocos/audio/apple/AudioPlayer.mm
@@ -25,9 +25,6 @@
#define LOG_TAG "AudioPlayer"
-#include "platform/CCPlatformConfig.h"
-#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
-
#import
#include "audio/apple/AudioPlayer.h"
@@ -42,7 +39,6 @@
#endif
using namespace cocos2d;
-using namespace cocos2d::experimental;
namespace {
unsigned int __idIndex = 0;
@@ -371,5 +367,3 @@ bool AudioPlayer::setTime(float time)
}
return false;
}
-
-#endif
diff --git a/cocos/audio/include/AudioEngine.h b/cocos/audio/include/AudioEngine.h
index 090183a257..ce6a4aa9a7 100644
--- a/cocos/audio/include/AudioEngine.h
+++ b/cocos/audio/include/AudioEngine.h
@@ -43,8 +43,6 @@
*/
NS_CC_BEGIN
-namespace experimental {
-
/**
* @class AudioProfile
*
@@ -368,7 +366,6 @@ protected:
friend class AudioEngineImpl;
};
-} // namespace experimental {
NS_CC_END
// end group
diff --git a/cocos/audio/linux/AudioEngine-linux.cpp b/cocos/audio/linux/AudioEngine-linux.cpp
index 0a9e89b860..80b886d894 100644
--- a/cocos/audio/linux/AudioEngine-linux.cpp
+++ b/cocos/audio/linux/AudioEngine-linux.cpp
@@ -34,7 +34,6 @@
#include "platform/CCFileUtils.h"
using namespace cocos2d;
-using namespace cocos2d::experimental;
AudioEngineImpl * g_AudioEngineImpl = nullptr;
diff --git a/cocos/audio/linux/AudioEngine-linux.h b/cocos/audio/linux/AudioEngine-linux.h
index d52a152e5b..06c5659826 100644
--- a/cocos/audio/linux/AudioEngine-linux.h
+++ b/cocos/audio/linux/AudioEngine-linux.h
@@ -39,7 +39,7 @@
#include "base/CCRef.h"
NS_CC_BEGIN
- namespace experimental{
+
#define MAX_AUDIOINSTANCES 32
class CC_DLL AudioEngineImpl : public cocos2d::Ref
@@ -102,7 +102,7 @@ private:
FMOD::System* pSystem;
};
-}
+
NS_CC_END
#endif // __AUDIO_ENGINE_LINUX_H_
#endif
diff --git a/cocos/audio/win32/AudioCache.cpp b/cocos/audio/win32/AudioCache.cpp
index 34ba49c880..702b6b62de 100644
--- a/cocos/audio/win32/AudioCache.cpp
+++ b/cocos/audio/win32/AudioCache.cpp
@@ -52,7 +52,6 @@ unsigned int __idIndex = 0;
#define PCMDATA_CACHEMAXSIZE 1048576
using namespace cocos2d;
-using namespace cocos2d::experimental;
AudioCache::AudioCache()
: _totalFrames(0)
@@ -249,7 +248,7 @@ void AudioCache::readDataTask(unsigned int selfId)
}
else
{
- _queBufferFrames = sampleRate * QUEUEBUFFER_TIME_STEP;
+ _queBufferFrames = static_cast(sampleRate * QUEUEBUFFER_TIME_STEP);
BREAK_IF_ERR_LOG(_queBufferFrames == 0, "_queBufferFrames == 0");
const uint32_t queBufferBytes = _queBufferFrames * bytesPerFrame;
diff --git a/cocos/audio/win32/AudioCache.h b/cocos/audio/win32/AudioCache.h
index b3c58f10ba..cb75fe918c 100644
--- a/cocos/audio/win32/AudioCache.h
+++ b/cocos/audio/win32/AudioCache.h
@@ -43,7 +43,6 @@
#include "audio/win32/AudioMacros.h"
NS_CC_BEGIN
-namespace experimental{
class AudioEngineImpl;
class AudioPlayer;
@@ -115,7 +114,6 @@ protected:
friend class AudioPlayer;
};
-}
NS_CC_END
#endif
diff --git a/cocos/audio/win32/AudioDecoder.cpp b/cocos/audio/win32/AudioDecoder.cpp
index 77d507777d..e05d1f9ec9 100644
--- a/cocos/audio/win32/AudioDecoder.cpp
+++ b/cocos/audio/win32/AudioDecoder.cpp
@@ -29,7 +29,7 @@
#define LOG_TAG "AudioDecoder"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoder::AudioDecoder()
: _isOpened(false)
@@ -89,4 +89,4 @@ AudioDecoder::AudioDecoder()
return _channelCount;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoder.h b/cocos/audio/win32/AudioDecoder.h
index c7f321b8cd..ca466c94ba 100644
--- a/cocos/audio/win32/AudioDecoder.h
+++ b/cocos/audio/win32/AudioDecoder.h
@@ -29,7 +29,7 @@
#include "vorbis/vorbisfile.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/**
* @brief The class for decoding compressed audio file to PCM buffer.
@@ -117,4 +117,4 @@ protected:
friend class AudioDecoderManager;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoderManager.cpp b/cocos/audio/win32/AudioDecoderManager.cpp
index 28ce2ca1e4..950c305355 100644
--- a/cocos/audio/win32/AudioDecoderManager.cpp
+++ b/cocos/audio/win32/AudioDecoderManager.cpp
@@ -33,7 +33,7 @@ THE SOFTWARE.
#include "base/CCConsole.h"
#include "mpg123.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
static bool __mp3Inited = false;
@@ -67,5 +67,5 @@ void AudioDecoderManager::destroyDecoder(AudioDecoder* decoder)
delete decoder;
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoderManager.h b/cocos/audio/win32/AudioDecoderManager.h
index ce80bdf1ff..d5295827a3 100644
--- a/cocos/audio/win32/AudioDecoderManager.h
+++ b/cocos/audio/win32/AudioDecoderManager.h
@@ -25,7 +25,7 @@ THE SOFTWARE.
#pragma once
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
class AudioDecoder;
@@ -38,5 +38,5 @@ public:
static void destroyDecoder(AudioDecoder* decoder);
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoderMp3.cpp b/cocos/audio/win32/AudioDecoderMp3.cpp
index c343f888d1..e6d5b3a94d 100644
--- a/cocos/audio/win32/AudioDecoderMp3.cpp
+++ b/cocos/audio/win32/AudioDecoderMp3.cpp
@@ -32,7 +32,7 @@
#define LOG_TAG "AudioDecoderMp3"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
static bool __mp3Inited = false;
@@ -181,4 +181,4 @@ namespace cocos2d { namespace experimental {
return static_cast(mpg123_tell(_mpg123handle));
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoderMp3.h b/cocos/audio/win32/AudioDecoderMp3.h
index a11db607f3..41b642b7d9 100644
--- a/cocos/audio/win32/AudioDecoderMp3.h
+++ b/cocos/audio/win32/AudioDecoderMp3.h
@@ -29,7 +29,7 @@
struct mpg123_handle_struct;
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/**
* @brief The class for decoding compressed audio file to PCM buffer.
@@ -83,4 +83,4 @@ protected:
friend class AudioDecoderManager;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoderOgg.cpp b/cocos/audio/win32/AudioDecoderOgg.cpp
index fc20453229..a5c5c7c6ab 100644
--- a/cocos/audio/win32/AudioDecoderOgg.cpp
+++ b/cocos/audio/win32/AudioDecoderOgg.cpp
@@ -29,7 +29,7 @@
#define LOG_TAG "AudioDecoderOgg"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
AudioDecoderOgg::AudioDecoderOgg()
{
@@ -84,4 +84,4 @@ namespace cocos2d { namespace experimental {
return static_cast(ov_pcm_tell(const_cast(&_vf)));
}
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioDecoderOgg.h b/cocos/audio/win32/AudioDecoderOgg.h
index 4c9ce9113c..13150677b1 100644
--- a/cocos/audio/win32/AudioDecoderOgg.h
+++ b/cocos/audio/win32/AudioDecoderOgg.h
@@ -29,7 +29,7 @@
#include "vorbis/vorbisfile.h"
-namespace cocos2d { namespace experimental {
+namespace cocos2d {
/**
* @brief The class for decoding compressed audio file to PCM buffer.
@@ -79,4 +79,4 @@ protected:
friend class AudioDecoderManager;
};
-}} // namespace cocos2d { namespace experimental {
+} // namespace cocos2d {
diff --git a/cocos/audio/win32/AudioEngine-win32.cpp b/cocos/audio/win32/AudioEngine-win32.cpp
index f779f4276e..168e445b1f 100644
--- a/cocos/audio/win32/AudioEngine-win32.cpp
+++ b/cocos/audio/win32/AudioEngine-win32.cpp
@@ -22,12 +22,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-#define LOG_TAG "AudioEngine-Win32"
-
-#include "platform/CCPlatformConfig.h"
-
-#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
-
#include "audio/win32/AudioEngine-win32.h"
#ifdef OPENAL_PLAIN_INCLUDES
@@ -45,6 +39,8 @@
#include
+#define LOG_TAG "AudioEngine-Win32"
+
// log, CCLOG aren't threadsafe, since we uses sub threads for parsing pcm data, threadsafe log output
// is needed. Define the following macros (ALOGV, ALOGD, ALOGI, ALOGW, ALOGE) for threadsafe log output.
@@ -105,7 +101,6 @@ void audioLog(const char * format, ...)
}
using namespace cocos2d;
-using namespace cocos2d::experimental;
static ALCdevice *s_ALDevice = nullptr;
static ALCcontext *s_ALContext = nullptr;
@@ -516,5 +511,3 @@ void AudioEngineImpl::uncacheAll()
{
_audioCaches.clear();
}
-
-#endif
diff --git a/cocos/audio/win32/AudioEngine-win32.h b/cocos/audio/win32/AudioEngine-win32.h
index 132c662662..9cfd0f51b8 100644
--- a/cocos/audio/win32/AudioEngine-win32.h
+++ b/cocos/audio/win32/AudioEngine-win32.h
@@ -22,12 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-#include "platform/CCPlatformConfig.h"
-
-#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
-
-#ifndef __AUDIO_ENGINE_INL_H_
-#define __AUDIO_ENGINE_INL_H_
+#pragma once
#include
@@ -39,7 +34,6 @@ NS_CC_BEGIN
class Scheduler;
-namespace experimental {
#define MAX_AUDIOINSTANCES 32
class CC_DLL AudioEngineImpl : public cocos2d::Ref
@@ -86,8 +80,5 @@ private:
int _currentAudioID;
Scheduler* _scheduler;
};
-}
-NS_CC_END
-#endif // __AUDIO_ENGINE_INL_H_
-#endif
+NS_CC_END
diff --git a/cocos/audio/win32/AudioPlayer.cpp b/cocos/audio/win32/AudioPlayer.cpp
index 4c3e512877..370c015982 100644
--- a/cocos/audio/win32/AudioPlayer.cpp
+++ b/cocos/audio/win32/AudioPlayer.cpp
@@ -22,12 +22,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
-#define LOG_TAG "AudioPlayer"
-
-#include "platform/CCPlatformConfig.h"
-
-#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#include "audio/win32/AudioPlayer.h"
#include "audio/win32/AudioCache.h"
#include "platform/CCFileUtils.h"
@@ -41,8 +35,9 @@
#define ALOGVV(...) do{} while(false)
#endif
+#define LOG_TAG "AudioPlayer"
+
using namespace cocos2d;
-using namespace cocos2d::experimental;
namespace {
unsigned int __idIndex = 0;
@@ -268,7 +263,7 @@ void AudioPlayer::rotateBufferThread(int offsetFrame)
bufferProcessed--;
if (_timeDirty) {
_timeDirty = false;
- offsetFrame = _currTime * decoder->getSampleRate();
+ offsetFrame = (int)(_currTime * decoder->getSampleRate());
decoder->seek(offsetFrame);
}
else {
@@ -343,5 +338,3 @@ bool AudioPlayer::setTime(float time)
}
return false;
}
-
-#endif
diff --git a/cocos/audio/win32/AudioPlayer.h b/cocos/audio/win32/AudioPlayer.h
index a7f8a579ed..362ede8fcf 100644
--- a/cocos/audio/win32/AudioPlayer.h
+++ b/cocos/audio/win32/AudioPlayer.h
@@ -22,13 +22,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
#pragma once
-#include "platform/CCPlatformConfig.h"
-
-#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
-
#include
#include
#include
@@ -42,7 +37,6 @@
#include "platform/CCPlatformMacros.h"
NS_CC_BEGIN
-namespace experimental{
class AudioCache;
class AudioEngineImpl;
@@ -93,8 +87,4 @@ protected:
friend class AudioEngineImpl;
};
-}
NS_CC_END
-
-#endif //CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
-
diff --git a/cocos/base/CCConfiguration.h b/cocos/base/CCConfiguration.h
index bd4405b5a4..5a2282c028 100644
--- a/cocos/base/CCConfiguration.h
+++ b/cocos/base/CCConfiguration.h
@@ -32,7 +32,6 @@ THE SOFTWARE.
#include "base/CCRef.h"
#include "base/CCValue.h"
-#include "platform/CCGL.h"
#include "3d/CCAnimate3D.h"
/**
diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp
index 970583fe35..b666520ef5 100644
--- a/cocos/base/CCConsole.cpp
+++ b/cocos/base/CCConsole.cpp
@@ -1278,8 +1278,8 @@ void Console::commandProjectionSubCommand3d(int /*fd*/, const std::string& /*arg
void Console::commandResolution(int /*fd*/, const std::string& args)
{
- int width, height, policy;
-
+ int policy;
+ float width, height;
std::istringstream stream( args );
stream >> width >> height>> policy;
@@ -1346,8 +1346,8 @@ void Console::commandTouchSubCommandTap(int fd, const std::string& args)
if((argv.size() == 3 ) && (Console::Utility::isFloat(argv[1]) && Console::Utility::isFloat(argv[2])))
{
- float x = utils::atof(argv[1].c_str());
- float y = utils::atof(argv[2].c_str());
+ float x = (float)utils::atof(argv[1].c_str());
+ float y = (float)utils::atof(argv[2].c_str());
std::srand ((unsigned)time(nullptr));
_touchId = rand();
@@ -1373,10 +1373,10 @@ void Console::commandTouchSubCommandSwipe(int fd, const std::string& args)
&& (Console::Utility::isFloat(argv[3])) && (Console::Utility::isFloat(argv[4])))
{
- float x1 = utils::atof(argv[1].c_str());
- float y1 = utils::atof(argv[2].c_str());
- float x2 = utils::atof(argv[3].c_str());
- float y2 = utils::atof(argv[4].c_str());
+ float x1 = (float)utils::atof(argv[1].c_str());
+ float y1 = (float)utils::atof(argv[2].c_str());
+ float x2 = (float)utils::atof(argv[3].c_str());
+ float y2 = (float)utils::atof(argv[4].c_str());
std::srand ((unsigned)time(nullptr));
_touchId = rand();
diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp
index cced6be39b..5031377c7b 100644
--- a/cocos/base/CCDirector.cpp
+++ b/cocos/base/CCDirector.cpp
@@ -203,8 +203,8 @@ void Director::setDefaultValues()
Configuration *conf = Configuration::getInstance();
// default FPS
- double fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).asDouble();
- _oldAnimationInterval = _animationInterval = 1.0 / fps;
+ float fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).asFloat();
+ _oldAnimationInterval = _animationInterval = 1.0f / fps;
// Display FPS
_displayStats = conf->getValue("cocos2d.x.display_fps", Value(false)).asBool();
@@ -1292,10 +1292,10 @@ void Director::createStatsLabel()
Texture2D::setDefaultAlphaPixelFormat(currentFormat);
- const int height_spacing = 22 / CC_CONTENT_SCALE_FACTOR();
- _drawnVerticesLabel->setPosition(Vec2(0, height_spacing*2) + CC_DIRECTOR_STATS_POSITION);
- _drawnBatchesLabel->setPosition(Vec2(0, height_spacing*1) + CC_DIRECTOR_STATS_POSITION);
- _FPSLabel->setPosition(Vec2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION);
+ const int height_spacing = (int)(22 / CC_CONTENT_SCALE_FACTOR());
+ _drawnVerticesLabel->setPosition(Vec2(0, height_spacing*2.0f) + CC_DIRECTOR_STATS_POSITION);
+ _drawnBatchesLabel->setPosition(Vec2(0, height_spacing*1.0f) + CC_DIRECTOR_STATS_POSITION);
+ _FPSLabel->setPosition(Vec2(0, height_spacing*0.0f)+CC_DIRECTOR_STATS_POSITION);
}
#endif // #if !CC_STRIP_FPS
diff --git a/cocos/base/CCDirector.h b/cocos/base/CCDirector.h
index d58e5a4a00..68bfe44c34 100644
--- a/cocos/base/CCDirector.h
+++ b/cocos/base/CCDirector.h
@@ -36,7 +36,6 @@ THE SOFTWARE.
#include "base/CCVector.h"
#include "2d/CCScene.h"
#include "math/CCMath.h"
-#include "platform/CCGL.h"
#include "platform/CCGLView.h"
NS_CC_BEGIN
diff --git a/cocos/base/CCStencilStateManager.cpp b/cocos/base/CCStencilStateManager.cpp
index 30e535810a..5b707d7a97 100644
--- a/cocos/base/CCStencilStateManager.cpp
+++ b/cocos/base/CCStencilStateManager.cpp
@@ -36,7 +36,8 @@ int StencilStateManager::s_layer = -1;
StencilStateManager::StencilStateManager()
{
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
- _programState = new (std::nothrow) backend::ProgramState(positionUColor_vert, positionUColor_frag);
+ auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_UCOLOR);
+ _programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;
auto vertexLayout = _programState->getVertexLayout();
diff --git a/cocos/base/ZipUtils.cpp b/cocos/base/ZipUtils.cpp
index 167ec94055..f69c263b7b 100644
--- a/cocos/base/ZipUtils.cpp
+++ b/cocos/base/ZipUtils.cpp
@@ -31,6 +31,8 @@
#else // from our embedded sources
#include "unzip.h"
#endif
+#include "ioapi_mem.h"
+#include
#include
#include
@@ -42,11 +44,9 @@
#include "platform/CCFileUtils.h"
#include