mirror of https://github.com/axmolengine/axmol.git
commit
72d605dc15
|
@ -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
|
||||
|
||||
|
|
|
@ -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/)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
</array>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -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
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 363 KiB |
Binary file not shown.
After Width: | Height: | Size: 252 KiB |
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<unsigned int>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <stddef.h> // 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");
|
||||
|
|
|
@ -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<cocos2d::Vec2> 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<Vec2> AutoPolygon::expand(const std::vector<Vec2>& 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<ClipperLib::cInt>(pt.x* PRECISION), static_cast<ClipperLib::cInt>(pt.y * PRECISION));
|
||||
}
|
||||
ClipperLib::ClipperOffset co;
|
||||
co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon);
|
||||
|
@ -551,9 +551,10 @@ std::vector<Vec2> AutoPolygon::expand(const std::vector<Vec2>& 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<ClipperLib::cInt>(rect.size.width/_scaleFactor * PRECISION), 0));
|
||||
clamp.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(rect.size.width/_scaleFactor * PRECISION),
|
||||
static_cast<ClipperLib::cInt>(rect.size.height/_scaleFactor * PRECISION)));
|
||||
clamp.push_back(ClipperLib::IntPoint(0, static_cast<ClipperLib::cInt>(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<Vec2>& 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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
****************************************************************************/
|
||||
#include "2d/CCCameraBackgroundBrush.h"
|
||||
#include <stddef.h> // 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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
|
||||
#include "2d/CCDrawNode.h"
|
||||
#include <stddef.h> // 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<ssize_t>(dt / deltaT);
|
||||
lt = (dt - deltaT * (float)p) / deltaT;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ THE SOFTWARE.
|
|||
|
||||
*/
|
||||
#include "2d/CCFastTMXLayer.h"
|
||||
#include <stddef.h> // 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<int>(std::max(0.f,visibleTiles.origin.y - tilesOverY));
|
||||
int yEnd = static_cast<int>(std::min(_layerSize.height,visibleTiles.origin.y + visibleTiles.size.height + tilesOverY));
|
||||
int xBegin = static_cast<int>(std::max(0.f,visibleTiles.origin.x - tilesOverX));
|
||||
int xEnd = static_cast<int>(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<unsigned short>(_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<uint8_t>(color.r * alpha);
|
||||
color.g = static_cast<uint8_t>(color.g * alpha);
|
||||
color.b = static_cast<uint8_t>(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("<FastTMXLayer | tag = %d, size = %d,%d>", _tag, (int)_mapTileSize.width, (int)_mapTileSize.height);
|
||||
}
|
||||
|
||||
} //end of namespace experimental
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<TMXLayer*>(child);
|
||||
FastTMXLayer* layer = dynamic_cast<FastTMXLayer*>(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("<FastTMXTiledMap | Tag = %d, Layers = %d", _tag, static_cast<int>(_children.size()));
|
||||
}
|
||||
|
||||
} //end of namespace experimental
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -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__
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ FontAtlas::FontAtlas(Font &theFont)
|
|||
_fontFreeType = dynamic_cast<FontFreeType*>(_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<FT_ULong>(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<FT_ULong>(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<FT_ULong>(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<FT_ULong>(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<float>(metrics.horiBearingX >> 6);
|
||||
outRect.origin.y = static_cast<float>(-(metrics.horiBearingY >> 6));
|
||||
outRect.size.width = static_cast<float>((metrics.width >> 6));
|
||||
outRect.size.height = static_cast<float>((metrics.height >> 6));
|
||||
|
||||
xAdvance = (static_cast<int>(_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<FT_ULong>(theChar), FT_LOAD_NO_BITMAP) == 0)
|
||||
{
|
||||
if (_fontRef->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
|
|
|
@ -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<size_t>((_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<size_t>(_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<size_t>((_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<size_t>((_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<size_t>((_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<unsigned int>(_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<unsigned int>((_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<size_t>(_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<size_t>(_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
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "2d/CCLabel.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <stddef.h> // 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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -809,22 +809,27 @@ void Node::enumerateChildren(const std::string &name, std::function<bool (Node *
|
|||
|
||||
// Remove '//', '/..' if exist
|
||||
std::string newName = name.substr(subStrStartPos, subStrlength);
|
||||
|
||||
|
||||
const Node* target = this;
|
||||
|
||||
if (searchFromParent)
|
||||
{
|
||||
newName.insert(0, "[[:alnum:]]+/");
|
||||
if (nullptr == _parent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
target = _parent;
|
||||
}
|
||||
|
||||
|
||||
if (searchRecursively)
|
||||
{
|
||||
// name is '//xxx'
|
||||
doEnumerateRecursive(this, newName, callback);
|
||||
target->doEnumerateRecursive(target, newName, callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
// name is xxx
|
||||
doEnumerate(newName, callback);
|
||||
target->doEnumerate(newName, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
*
|
||||
*/
|
||||
#include "2d/CCParticleBatchNode.h"
|
||||
#include <stddef.h> // 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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 <algorithm>
|
||||
|
||||
#include <stddef.h> // 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");
|
||||
|
|
|
@ -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 <algorithm>
|
||||
|
||||
#include <stddef.h> // 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;
|
||||
|
||||
|
|
|
@ -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<void(Image*)> 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);
|
||||
|
|
|
@ -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 <algorithm>
|
||||
|
||||
#include <stddef.h> // 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<Texture2D*>(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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 <stddef.h> // 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");
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -424,7 +424,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vec2& pos)
|
|||
|
||||
for(const auto &child : _children) {
|
||||
Sprite* sp = static_cast<Sprite*>(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<unsigned int>(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<Sprite*>(obj);
|
||||
ssize_t ai = child->getAtlasIndex();
|
||||
auto ai = child->getAtlasIndex();
|
||||
if ( ai >= atlasIndex )
|
||||
{
|
||||
child->setAtlasIndex(ai-1);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -100,7 +100,7 @@ void getChildMap(std::map<int, std::vector<int> >& 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();
|
||||
|
|
|
@ -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 <stddef.h> // 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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -29,12 +29,14 @@ USING_NS_CC;
|
|||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
#include <set>
|
||||
#include <stddef.h> // 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 $<$<COMPILE_LANGUAGE:CXX>:-fno-aligned-allocation>)
|
||||
#endif()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -26,7 +26,7 @@ THE SOFTWARE.
|
|||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
|
||||
class AssetFd
|
||||
{
|
||||
|
@ -39,5 +39,5 @@ private:
|
|||
int _assetFd;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdint.h>
|
||||
#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 {
|
||||
|
|
|
@ -34,7 +34,7 @@ THE SOFTWARE.
|
|||
#include <chrono>
|
||||
#include <stdlib.h>
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
|
||||
class AudioDecoderSLES : public AudioDecoder
|
||||
{
|
||||
|
@ -94,4 +94,4 @@ private:
|
|||
friend class AudioDecoderProvider;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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 {
|
||||
} // namespace cocos2d {
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -33,7 +33,7 @@ THE SOFTWARE.
|
|||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
|
||||
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 {
|
||||
|
|
|
@ -33,7 +33,7 @@ THE SOFTWARE.
|
|||
#include <atomic>
|
||||
#include <vector>
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ THE SOFTWARE.
|
|||
#include <stdlib.h>
|
||||
#include <algorithm> // 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 {
|
||||
|
|
|
@ -33,7 +33,7 @@ THE SOFTWARE.
|
|||
#include <memory>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
// Manage PcmAudioPlayer& UrlAudioPlayer
|
||||
|
||||
class PcmAudioPlayer;
|
||||
|
@ -124,5 +124,5 @@ private:
|
|||
ThreadPool* _threadPool;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <assert.h>
|
||||
#include "audio/android/audio.h"
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
|
||||
|
||||
class AudioResampler {
|
||||
|
@ -178,4 +178,4 @@ private:
|
|||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
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 {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <vector>
|
||||
#include <atomic>
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
|
||||
/**
|
||||
* @addtogroup base
|
||||
|
@ -234,4 +234,4 @@ private:
|
|||
// end of base group
|
||||
/// @}
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include <functional>
|
||||
|
||||
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 {
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#include <functional>
|
||||
#include <thread>
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<char> __silenceData;
|
||||
|
||||
|
@ -197,4 +197,4 @@ void PcmAudioService::resume()
|
|||
}
|
||||
}
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
|
|
@ -32,7 +32,7 @@ THE SOFTWARE.
|
|||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
|
||||
class AudioMixerController;
|
||||
|
||||
|
@ -79,4 +79,4 @@ private:
|
|||
friend class AudioPlayerProvider;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace cocos2d { namespace experimental {
|
||||
namespace cocos2d {
|
||||
|
||||
struct PcmData
|
||||
{
|
||||
|
@ -63,4 +63,4 @@ struct PcmData
|
|||
std::string toString() const;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace experimental {
|
||||
} // namespace cocos2d {
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
|
||||
#include <math.h>
|
||||
|
||||
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 {
|
||||
} // namespace cocos2d {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue