Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into issue#3781

This commit is contained in:
lihex 2014-02-10 10:43:16 +08:00
commit 1fbde6d8d5
1596 changed files with 32051 additions and 43429 deletions

1
.gitignore vendored
View File

@ -60,7 +60,6 @@ build_*_vc10/
*.mode*v* *.mode*v*
*.pbxuser *.pbxuser
*.xcbkptlist *.xcbkptlist
*.xcscheme
*.xcworkspacedata *.xcworkspacedata
*.xcuserstate *.xcuserstate
*.xccheckout *.xccheckout

6
.gitmodules vendored
View File

@ -4,12 +4,12 @@
[submodule "cocos/scripting/auto-generated"] [submodule "cocos/scripting/auto-generated"]
path = cocos/scripting/auto-generated path = cocos/scripting/auto-generated
url = git://github.com/cocos2d-x/bindings-auto-generated.git url = git://github.com/cocos2d-x/bindings-auto-generated.git
[submodule "samples/Javascript/Shared"]
path = samples/Javascript/Shared
url = git://github.com/cocos2d/cocos2d-js-tests.git
[submodule "tools/cocos2d-console"] [submodule "tools/cocos2d-console"]
path = tools/cocos2d-console path = tools/cocos2d-console
url = git://github.com/cocos2d/cocos2d-console.git url = git://github.com/cocos2d/cocos2d-console.git
[submodule "plugin"] [submodule "plugin"]
path = plugin path = plugin
url = https://github.com/cocos2d-x/plugin-x.git url = https://github.com/cocos2d-x/plugin-x.git
[submodule "tests/test-javascript/tests"]
path = tests/test-javascript/tests
url = git://github.com/cocos2d/cocos2d-js-tests.git

View File

@ -95,6 +95,7 @@ Developers:
Added Mingw-crt Support without breaking VS SDK Added Mingw-crt Support without breaking VS SDK
CMake support for windows. CMake support for windows.
Added support for x64 target of windows. Added support for x64 target of windows.
Added Dutch Language support.
mchinen mchinen
fix emulator issue for OpenGL ES 2.0 on Android fix emulator issue for OpenGL ES 2.0 on Android
@ -511,6 +512,7 @@ Developers:
Lee, Jae-Hong (pyrasis) Lee, Jae-Hong (pyrasis)
Maintainer of tizen port. Maintainer of tizen port.
localStorageGetItem crashes when column text is NULL. localStorageGetItem crashes when column text is NULL.
fix image bug on Android
lumendes lumendes
Updating spine-runtime to EsotericSoftware/spine-runtimes@5f90386. Updating spine-runtime to EsotericSoftware/spine-runtimes@5f90386.
@ -723,6 +725,7 @@ Developers:
hbbalfred hbbalfred
Fixed a bug that crash if file doesn't exist when using FileUtils::getStringFromFile. Fixed a bug that crash if file doesn't exist when using FileUtils::getStringFromFile.
Fixed a bug that cc.BuilderReader.load( path, null, parentSize ); was not allowed.
liang8305 liang8305
Use multiple processes according the number of cores to build android project Use multiple processes according the number of cores to build android project
@ -730,6 +733,9 @@ Developers:
pandamicro pandamicro
Exposed SAXParser to JS, it is used for parsing XML in JS. Exposed SAXParser to JS, it is used for parsing XML in JS.
hanjukim
Fixed a bug that color and opacity settings were not applied when invoking Label::alignText.
Retired Core Developers: Retired Core Developers:
WenSheng Yang WenSheng Yang
Author of windows port, CCTextField, Author of windows port, CCTextField,

View File

@ -1,5 +1,15 @@
cocos2d-x-3.0beta2 ?.? ? cocos2d-x-3.0rc0 Feb.?? 2014
[All] [All]
[NEW] Adds Dutch Language support.
[NEW] Console: Added 'resolution', 'projection' commands. Improved API
[FIX] EGLView improvements: renamed to GLView, no longer a singleton, easier to customize
[FIX] Removes samples except testcpp|testjavascript|testlua. Moves sample games to `cocos2d/samples` repo.
[FIX] cc.BuilderReader.load( path, null, parentSize ); was not allowed.
cocos2d-x-3.0beta2 Jan.24 2014
[All]
[NEW] Full screen support for desktop platforms.
[NEW] Adds performance test for EventDispatcher. [NEW] Adds performance test for EventDispatcher.
[NEW] Adds performance test for Containers(Vector<>, Array, Map<K,V>, Dictionary). [NEW] Adds performance test for Containers(Vector<>, Array, Map<K,V>, Dictionary).
[NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier. [NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier.
@ -9,18 +19,22 @@ cocos2d-x-3.0beta2 ?.? ?
[NEW] Label: Integrates LabelAtlas into new Label. [NEW] Label: Integrates LabelAtlas into new Label.
[NEW] Node: Added `setGlobalZOrder()`. Useful to change the Node's render order. Node::setZOrder() -> Node::setLocalZOrder() [NEW] Node: Added `setGlobalZOrder()`. Useful to change the Node's render order. Node::setZOrder() -> Node::setLocalZOrder()
[NEW] Renderer: Added BatchCommand. This command is not "batchable" with other commands, but improves performance in about 10% [NEW] Renderer: Added BatchCommand. This command is not "batchable" with other commands, but improves performance in about 10%
[NEW] LuaBindings: Bindings-generator supports to bind namespace for lua.
[FIX] Exposes SAXParser class to JS, it is used for parsing XML in JS. [FIX] event->stopPropagation can't work for EventListenerTouchAllAtOnce.
[FIX] Uses unified `desktop/CCEGLView.h/cpp` for desktop platforms (windows, mac, linux). [FIX] Uses unified `desktop/CCEGLView.h/cpp` for desktop platforms (windows, mac, linux).
[FIX] Bindings-generator supports Windows again and remove dependency of LLVM since we only need binary(libclang.so/dll). [FIX] Bindings-generator supports Windows again and remove dependency of LLVM since we only need binary(libclang.so/dll).
[FIX] Removes unused files for MAC platform after using glfw3 to create opengl context. [FIX] Removes unused files for MAC platform after using glfw3 to create opengl context.
[FIX] Wrong arithmetic of child's position in ParallaxNode::addChild() [FIX] Wrong arithmetic of child's position in ParallaxNode::addChild()
[FIX] CocoStudio: TestColliderDetector in ArmatureTest can't work. [FIX] CocoStudio: TestColliderDetector in ArmatureTest can't work.
[FIX] CocoStudio: The order of transform calculation in Skin::getNodeToWorldTransform() is incorrect.
[FIX] Crash if file doesn't exist when using FileUtils::getStringFromFile. [FIX] Crash if file doesn't exist when using FileUtils::getStringFromFile.
[FIX] If setting a shorter string than before while using LabelAtlas, the effect will be wrong. [FIX] If setting a shorter string than before while using LabelAtlas, the effect will be wrong.
[FIX] Label: Memory leak in FontFreeType::createFontAtlas().
[FIX] Label: Crash when using unknown characters. [FIX] Label: Crash when using unknown characters.
[FIX] Label: Missing line breaks and wrong alignment. [FIX] Label: Missing line breaks and wrong alignment.
[FIX] Label: Corrupt looking characters and incorrect spacing between characters
[FIX] Label: Label:color and opacity settings are invalid afeter these these properties changed: 1)text content changed 2)align style changed 3)max line width limited
[FIX] Label: Crash when using unknown characters
[FIX] Console: log(format, va_args) is private to prevent possible resolution errors [FIX] Console: log(format, va_args) is private to prevent possible resolution errors
[FIX] Configuration: dumpInfo() -> getInfo() [FIX] Configuration: dumpInfo() -> getInfo()
[FIX] ControlSlider doesn't support to set selected thumb sprite. [FIX] ControlSlider doesn't support to set selected thumb sprite.
@ -32,12 +46,42 @@ cocos2d-x-3.0beta2 ?.? ?
[FIX] Renderer Performance Fix: When note using VAO, call glBufferData() instead of glBufferSubData(). [FIX] Renderer Performance Fix: When note using VAO, call glBufferData() instead of glBufferSubData().
[FIX] Renderer Performance Fix: Doesn't sort z=0 elements. It also uses sort() instead of stable_sort() for z!=0. [FIX] Renderer Performance Fix: Doesn't sort z=0 elements. It also uses sort() instead of stable_sort() for z!=0.
[FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well [FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well
[FIX] Tests: TestCpp works with CMake on Windows.
[FIX] Tests: Sprites Performance Test has 4 new tests [FIX] Tests: Sprites Performance Test has 4 new tests
[FIX] TextureCache: getTextureForKey and removeTextureForKey work as expected [FIX] TextureCache: getTextureForKey and removeTextureForKey work as expected
[FIX] TextureCache: dumpCachedTextureInfo() -> getCachedTextureInfo() [FIX] TextureCache: dumpCachedTextureInfo() -> getCachedTextureInfo()
[FIX] Websocket doesn't support send/receive data which larger than 4096 bytes. [FIX] Websocket doesn't support send/receive data which larger than 4096 bytes.
[FIX] Windows: There will be some compilation errors when using x64 target on Windows. [FIX] Object: Remove _retainCount
[FIX] ParallaxNode: Coordinate of Sprite may be wrong after being added into ParallaxNode
[FIX] Crash if there is not `textureFileName`section in particle plist file
[FIX] Websocket cannot send/receive more than 4096 bytes data
[FIX] TextureCache::addImageAsync can't load first image
[FIX] ControlSlider: Can not set "selected thumb sprite"
[FIX] ControlSlider: Can not set "scale ratio"
[FIX] Crash when loading tga format image
[FIX] Keyboard pressed events are being repeatedly fired before keyboard is released
[Android]
[FIX] Background music can't be resumed when back from foreground
[FIX] ANR (Application Not Responding) appears on android 2.3 when pressing hardware button.
[lua binding]
[NEW] Can bind classes that have the same class names but different namesapces
[FIX] Use EventDispatcher to update some test cases
[FIX] sp.SkeletonAnimation:registerScriptHandler should not override cc.Node:registerScriptHandler
[javascript binding]
[NEW] Bind SAXParser
[FIX] Pure JS class that wants to inherite from cc.Class will trigger an irrelevant log
[FIX] Mac and iOS Simulator should also use SpiderMonkey which was built in RELEASE mode
[FIX] Crash when running JSB projects on iOS device in DEBUG mode
[FIX] Crash when Firefox connects to JSB application on Mac platform.
[Desktop]
[NEW] Support fullscreen
[Linux]
[FIX] "Testing empty labels" in LabelTest crashes.
[Mac]
[FIX] Removes unused files after using glfw3 to create opengl context
[Win32]
[FIX] Compiling error when using x64 target
[FIX] Tests: TestCpp works with CMake
[FIX] Bindings-generator supports Windows again and remove dependency of LLVM since it only needs binary of libclang
cocos2d-x-3.0beta Jan.7 2014 cocos2d-x-3.0beta Jan.7 2014
[All] [All]
@ -784,7 +828,7 @@ cocos2d-2.0-x-2.0.2 @Aug.30 2012
Refactor #1399: adjust directory structure Refactor #1399: adjust directory structure
Refactor #1402: improve static creator function names to avoid confusion Refactor #1402: improve static creator function names to avoid confusion
Refactor #1413: improve CCTouch::getLocation(), getDelta() which returns OpenGL coordinates directly Refactor #1413: improve CCTouch::getLocation(), getDelta() which returns OpenGL coordinates directly
Refactor #1437: change the return type of CCApplication::sharedApplication() and CCEGLView::sharedOpenGLView() to a pointer Refactor #1437: change the return type of CCApplication::sharedApplication() and CCGLView::sharedOpenGLView() to a pointer
Refactor #1441: put hd and iPad resources of TestCpp into separate directories Refactor #1441: put hd and iPad resources of TestCpp into separate directories
Refactor #1442: use CREATE_FUNC to replace LAYER_CREATE_FUNC and SCENE_CREATE_FUNC Refactor #1442: use CREATE_FUNC to replace LAYER_CREATE_FUNC and SCENE_CREATE_FUNC
[iOS] [iOS]
@ -818,7 +862,7 @@ cocos2d-2.0-rc2-x-2.0.1 @Jun.28 2012
Bug #1293: fix a bug that CCDirector::getFrames() returns wrong value Bug #1293: fix a bug that CCDirector::getFrames() returns wrong value
Bug #1296: fix a logical error in CCTMXTiledMap::tilesetForLayer() Bug #1296: fix a logical error in CCTMXTiledMap::tilesetForLayer()
Bug #1300: fix a typo of CC_ENABLE_CACHE_TEXTTURE_DATA Bug #1300: fix a typo of CC_ENABLE_CACHE_TEXTTURE_DATA
Bug #1301: apply scissor with points in CCEGLView::sharedOpenGLView().setScissorInPoints() Bug #1301: apply scissor with points in CCGLView::sharedOpenGLView().setScissorInPoints()
Bug #1302: change the parameter type of CCMenu::setHandlerPriority to signed int Bug #1302: change the parameter type of CCMenu::setHandlerPriority to signed int
Bug #1308: fix a logical bug in CCTouchDispatcher Bug #1308: fix a logical bug in CCTouchDispatcher
Bug #1326: fix a bug that the compilation of HelloLua and testjs project was broken after synchronizing to rc2 Bug #1326: fix a bug that the compilation of HelloLua and testjs project was broken after synchronizing to rc2

View File

@ -45,9 +45,7 @@ option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
option(BUILD_HelloCpp "Only build HelloCpp sample" ON)
option(BUILD_TestCpp "Only build TestCpp sample" ON) option(BUILD_TestCpp "Only build TestCpp sample" ON)
option(BUILD_HelloLua "Only build HelloLua sample" OFF)
option(BUILD_TestLua "Only build TestLua sample" OFF) option(BUILD_TestLua "Only build TestLua sample" OFF)
else()#temp else()#temp
@ -63,10 +61,7 @@ option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
option(BUILD_HelloCpp "Only build HelloCpp sample" ON)
option(BUILD_TestCpp "Only build TestCpp sample" ON) option(BUILD_TestCpp "Only build TestCpp sample" ON)
option(BUILD_HelloLua "Only build HelloLua sample" ON)
option(BUILD_TestLua "Only build TestLua sample" ON) option(BUILD_TestLua "Only build TestLua sample" ON)
endif()#temp endif()#temp
@ -170,7 +165,7 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include
external/curl/include/${PLATFORM_FOLDER} external/curl/include/${PLATFORM_FOLDER}
) )
elseif(APPLE) elseif(APPLE)
include_directories( include_directories(
@ -178,8 +173,9 @@ elseif(APPLE)
) )
else() else()
include_directories( include_directories(
/usr/include
/usr/local/include/GLFW
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER}/${ARCH_DIR}
) )
endif() endif()
@ -193,8 +189,8 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt
) )
endif() endif()
@ -209,7 +205,6 @@ else()
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR}
) )
@ -284,20 +279,13 @@ add_subdirectory(external/lua/tolua)
add_subdirectory(cocos/scripting) add_subdirectory(cocos/scripting)
endif(BUILD_LIBS_LUA) endif(BUILD_LIBS_LUA)
# build samples # build tests
if(BUILD_HelloCpp)
add_subdirectory(samples/Cpp/HelloCpp)
endif(BUILD_HelloCpp)
if(BUILD_TestCpp) if(BUILD_TestCpp)
add_subdirectory(samples/Cpp/TestCpp) add_subdirectory(tests/test-cpp)
endif(BUILD_TestCpp) endif(BUILD_TestCpp)
if(BUILD_HelloLua)
add_subdirectory(samples/Lua/HelloLua)
endif(BUILD_HelloLua)
if(BUILD_TestLua) if(BUILD_TestLua)
add_subdirectory(samples/Lua/TestLua) add_subdirectory(tests/test-lua)
endif(BUILD_TestLua) endif(BUILD_TestLua)

View File

@ -1,26 +1,33 @@
#!/usr/bin/python #!/usr/bin/python
# android-build.py # android-build.py
# Build android samples # Build android
import sys import sys
import os, os.path import os, os.path
import shutil import shutil
from optparse import OptionParser from optparse import OptionParser
CPP_SAMPLES = ['hellocpp', 'testcpp', 'simplegame', 'assetsmanager'] CPP_SAMPLES = ['testcpp']
LUA_SAMPLES = ['hellolua', 'testlua'] LUA_SAMPLES = ['testlua']
JSB_SAMPLES = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme'] JSB_SAMPLES = ['testjavascript']
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES
def get_num_of_cpu(): def get_num_of_cpu():
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
''' '''
try: try:
from numpy.distutils import cpuinfo platform = sys.platform
return cpuinfo.cpu._getNCPUs() if platform == 'win32':
if 'NUMBER_OF_PROCESSORS' in os.environ:
return int(os.environ['NUMBER_OF_PROCESSORS'])
else:
return 1
else:
from numpy.distutils import cpuinfo
return cpuinfo.cpu._getNCPUs()
except Exception: except Exception:
print "Can't know cpuinfo, use default 1 cpu" print "Can't know cpuinfo, use default 1 cpu"
return 1 return 1
def check_environment_variables(): def check_environment_variables():
''' Checking the environment NDK_ROOT, which will be used for building ''' Checking the environment NDK_ROOT, which will be used for building
@ -67,9 +74,9 @@ def select_toolchain_version():
def caculate_built_samples(args): def caculate_built_samples(args):
''' Compute the sampels to be built ''' Compute the sampels to be built
'cpp' for short of all cpp samples 'cpp' for short of all cpp tests
'lua' for short of all lua smpleas 'lua' for short of all lua tests
'jsb' for short of all javascript samples 'jsb' for short of all javascript tests
''' '''
if 'all' in args: if 'all' in args:
@ -152,47 +159,23 @@ def copy_resources(target, app_android_root):
# jsb samples should copy javascript files and resources(shared with cocos2d-html5) # jsb samples should copy javascript files and resources(shared with cocos2d-html5)
if target in JSB_SAMPLES: if target in JSB_SAMPLES:
resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/javascript/script") resources_dir = os.path.join(app_android_root, "../../../cocos/scripting/javascript/script")
copy_files(resources_dir, assets_dir) copy_files(resources_dir, assets_dir)
if target == "cocosdragon":
resources_dir = os.path.join(app_android_root, "../../Shared/games/CocosDragonJS/Published files Android")
if target == "crystalcraze":
resources_dir = os.path.join(app_android_root, "../../Shared/games/CrystalCraze/Published-Android")
if target == "testjavascript": if target == "testjavascript":
resources_dir = os.path.join(app_android_root, "../../Shared/tests/") resources_dir = os.path.join(app_android_root, "../tests/")
if target == "watermelonwithme":
resources_dir = os.path.join(app_android_root, "../../Shared/games/WatermelonWithMe")
if target != "moonwarriors":
copy_files(resources_dir, assets_dir)
else:
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res")
dst_dir = os.path.join(assets_dir, "res")
os.mkdir(dst_dir)
copy_files(resources_dir, dst_dir)
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/src")
dst_dir = os.path.join(assets_dir, "src")
os.mkdir(dst_dir)
copy_files(resources_dir, dst_dir)
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors")
for item in os.listdir(resources_dir):
path = os.path.join(resources_dir, item)
if item.endswith('.js') and os.path.isfile(path):
shutil.copy(path, assets_dir)
# AssetsManager test should also copy javascript files
if target == "assetsmanager":
resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/javascript/script")
copy_files(resources_dir, assets_dir) copy_files(resources_dir, assets_dir)
# lua samples should copy lua script # lua samples should copy lua script
if target in LUA_SAMPLES: if target in LUA_SAMPLES:
resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/lua/script") resources_dir = os.path.join(app_android_root, "../../../cocos/scripting/lua/script")
copy_files(resources_dir, assets_dir) copy_files(resources_dir, assets_dir)
# TestLua shared resources with TestCpp # TestLua shared resources with TestCpp
if target == "testlua": if target == "testlua":
resources_dir = os.path.join(app_android_root, "../../../Cpp/TestCpp/Resources") resources_dir = os.path.join(app_android_root, "../../test-cpp/Resources")
copy_files(resources_dir, assets_dir) copy_files(resources_dir, assets_dir)
def build_samples(target,ndk_build_param,android_platform,build_mode): def build_samples(target,ndk_build_param,android_platform,build_mode):
@ -206,12 +189,12 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
cocos_root = os.path.join(current_dir, "..") cocos_root = os.path.join(current_dir, "..")
if android_platform is not None: if android_platform is not None:
sdk_root = check_environment_variables_sdk() sdk_root = check_environment_variables_sdk()
if android_platform.isdigit(): if android_platform.isdigit():
android_platform = 'android-'+android_platform android_platform = 'android-'+android_platform
else: else:
print 'please use vaild android platform' print 'please use vaild android platform'
exit(1) exit(1)
if build_mode is None: if build_mode is None:
build_mode = 'debug' build_mode = 'debug'
@ -220,28 +203,12 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
app_android_root = '' app_android_root = ''
for target in build_targets: for target in build_targets:
if target == 'hellocpp': if target == 'testcpp':
app_android_root = os.path.join(cocos_root, 'samples/Cpp/HelloCpp/proj.android') app_android_root = os.path.join(cocos_root, 'tests/test-cpp/proj.android')
elif target == 'testcpp':
app_android_root = os.path.join(cocos_root, 'samples/Cpp/TestCpp/proj.android')
elif target == 'simplegame':
app_android_root = os.path.join(cocos_root, 'samples/Cpp/SimpleGame/proj.android')
elif target == 'assetsmanager':
app_android_root = os.path.join(cocos_root, 'samples/Cpp/AssetsManagerTest/proj.android')
elif target == 'hellolua':
app_android_root = os.path.join(cocos_root, 'samples/Lua/HelloLua/proj.android')
elif target == 'testlua': elif target == 'testlua':
app_android_root = os.path.join(cocos_root, 'samples/Lua/TestLua/proj.android') app_android_root = os.path.join(cocos_root, 'tests/test-lua/proj.android')
elif target == 'cocosdragon':
app_android_root = os.path.join(cocos_root, 'samples/Javascript/CocosDragonJS/proj.android')
elif target == 'crystalcraze':
app_android_root = os.path.join(cocos_root, 'samples/Javascript/CrystalCraze/proj.android')
elif target == 'moonwarriors':
app_android_root = os.path.join(cocos_root, 'samples/Javascript/MoonWarriors/proj.android')
elif target == 'testjavascript': elif target == 'testjavascript':
app_android_root = os.path.join(cocos_root, 'samples/Javascript/TestJavascript/proj.android') app_android_root = os.path.join(cocos_root, 'tests/test-javascript/proj.android')
elif target == 'watermelonwithme':
app_android_root = os.path.join(cocos_root, 'samples/Javascript/WatermelonWithMe/proj.android')
else: else:
print 'unknown target: %s' % target print 'unknown target: %s' % target
continue continue
@ -253,19 +220,40 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
if __name__ == '__main__': if __name__ == '__main__':
#parse the params #parse the params
usage = """usage: %prog [options] target usage = """
This script is mainy used for building tests built-in with cocos2d-x.
Valid targets are: [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon|crystalcraze|moonwarriors|testjavascript|watermelonwithme] Usage: %prog [options] target
You can use [all|cpp|lua|jsb], to build all, or all the C++, or all the Lua, or all the JavaScript samples respectevely.""" Valid targets are: [testcpp|testlua|testjavascript]. You can combine them arbitrarily with a whitespace among two valid targets.
You can use [all|cpp|lua|jsb], to build all the tests, or all the c++ tests, or all the Lua tests, or all the JavaScript tests respectevely.
cpp = ['testcpp']
lua = ['testlua']
jsb = ['testjavascript']
all = cpp + lua + jsb // be careful with the all target, it may took a very long time to compile all the projects, do it under your own risk.
If you are new to cocos2d-x, I recommend you start with testcpp, testlua or testjavascript.
You can combine these targets like this:
//1. to build simplegame and assetsmanager
python android-build.py -p 10 testcpp testlua
//2. to build testlua and all the jsb tests
python android-build.py -p 19 testlua jsb
Note: You should install ant to generate apk while building the andriod tests. But it is optional. You can generate apk with eclipse.
"""
parser = OptionParser(usage=usage) parser = OptionParser(usage=usage)
parser.add_option("-n", "--ndk", dest="ndk_build_param", parser.add_option("-n", "--ndk", dest="ndk_build_param",
help='parameter for ndk-build') help='Parameter for ndk-build')
parser.add_option("-p", "--platform", dest="android_platform", parser.add_option("-p", "--platform", dest="android_platform",
help='parameter for android-update.Without the parameter,the script just build dynamic library for project. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]') help='Parameter for android-update. Without the parameter,the script just build dynamic library for the projects. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]')
parser.add_option("-b", "--build", dest="build_mode", parser.add_option("-b", "--build", dest="build_mode",
help='the build mode for java project,debug[default] or release.Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html') help='The build mode for java project,debug[default] or release. Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()
if len(args) == 0: if len(args) == 0:

View File

@ -5,15 +5,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos\audio\
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "..\samples\Cpp\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "..\samples\Cpp\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "..\tests\test-cpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}"
EndProject EndProject
@ -25,29 +23,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\cocos\netw
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "..\samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "..\samples\Javascript\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "..\tests\test-javascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDragonJS", "..\samples\Javascript\CocosDragonJS\proj.win32\CocosDragonJS.vcxproj", "{68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "..\samples\Javascript\CrystalCraze\proj.win32\CrystalCraze.vcxproj", "{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MoonWarriors", "..\samples\Javascript\MoonWarriors\proj.win32\MoonWarriors.vcxproj", "{1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WatermelonWithMe", "..\samples\Javascript\WatermelonWithMe\proj.win32\WatermelonWithMe.vcxproj", "{BE092D9E-95AE-4F86-84CE-F4519E4F3F15}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "..\samples\Lua\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "..\tests\test-lua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "..\samples\Lua\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleGame", "..\samples\Cpp\SimpleGame\proj.win32\SimpleGame.vcxproj", "{E0E282F4-8487-452C-BFAB-CB960EB4D22F}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForBuilder", "..\cocos\scripting\javascript\bindings\cocosbuilder\libJSBindingForBuilder.vcxproj", "{F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForBuilder", "..\cocos\scripting\javascript\bindings\cocosbuilder\libJSBindingForBuilder.vcxproj", "{F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}"
EndProject EndProject

View File

@ -1 +1 @@
e706fcdbf8b76069d794bc03e3849a57932cdf0a caae58ff83f2655d5ea4c19e00a2be17259f8559

View File

@ -1 +0,0 @@
7a606b7819e4f2a8d7eb689a029974d84d57cf63

View File

@ -0,0 +1 @@
88d35147fd70ffbc353388aa9424bd2f0645ac95

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A035A5441782290400987F6C"
BuildableName = "Test JavaScript Mac.app"
BlueprintName = "Test JavaScript Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A035A5441782290400987F6C"
BuildableName = "Test JavaScript Mac.app"
BlueprintName = "Test JavaScript Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A035A5441782290400987F6C"
BuildableName = "Test JavaScript Mac.app"
BlueprintName = "Test JavaScript Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A035A5441782290400987F6C"
BuildableName = "Test JavaScript Mac.app"
BlueprintName = "Test JavaScript Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A01E16C01784C06E00B0CA4A"
BuildableName = "Test JavaScript iOS.app"
BlueprintName = "Test JavaScript iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A01E16C01784C06E00B0CA4A"
BuildableName = "Test JavaScript iOS.app"
BlueprintName = "Test JavaScript iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A01E16C01784C06E00B0CA4A"
BuildableName = "Test JavaScript iOS.app"
BlueprintName = "Test JavaScript iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A01E16C01784C06E00B0CA4A"
BuildableName = "Test JavaScript iOS.app"
BlueprintName = "Test JavaScript iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "Test cpp Mac.app"
BlueprintName = "Test cpp Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "Test cpp Mac.app"
BlueprintName = "Test cpp Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "Test cpp Mac.app"
BlueprintName = "Test cpp Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "Test cpp Mac.app"
BlueprintName = "Test cpp Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A07A517F1783A1D20073F6A7"
BuildableName = "Test cpp iOS.app"
BlueprintName = "Test cpp iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A07A517F1783A1D20073F6A7"
BuildableName = "Test cpp iOS.app"
BlueprintName = "Test cpp iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A07A517F1783A1D20073F6A7"
BuildableName = "Test cpp iOS.app"
BlueprintName = "Test cpp iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A07A517F1783A1D20073F6A7"
BuildableName = "Test cpp iOS.app"
BlueprintName = "Test cpp iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A6FB7821785614200CDF010"
BuildableName = "Test lua Mac.app"
BlueprintName = "Test lua Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A6FB7821785614200CDF010"
BuildableName = "Test lua Mac.app"
BlueprintName = "Test lua Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A6FB7821785614200CDF010"
BuildableName = "Test lua Mac.app"
BlueprintName = "Test lua Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A6FB7821785614200CDF010"
BuildableName = "Test lua Mac.app"
BlueprintName = "Test lua Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A11982D178538E400D62A44"
BuildableName = "Test lua iOS.app"
BlueprintName = "Test lua iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A11982D178538E400D62A44"
BuildableName = "Test lua iOS.app"
BlueprintName = "Test lua iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A11982D178538E400D62A44"
BuildableName = "Test lua iOS.app"
BlueprintName = "Test lua iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A11982D178538E400D62A44"
BuildableName = "Test lua iOS.app"
BlueprintName = "Test lua iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A035ACBB1782469700987F6C"
BuildableName = "build-all-tests Mac"
BlueprintName = "build-all-tests Mac"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A07A517B1783A1CC0073F6A7"
BuildableName = "build-all-tests iOS"
BlueprintName = "build-all-tests iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,8 +0,0 @@
@echo off
SETLOCAL
:start
mkdir win32-msvc-vs2010-x86
cd win32-msvc-vs2010-x86
cmake -G "Visual Studio 10" ../..
pause

View File

@ -111,7 +111,7 @@ cocos2d.cpp \
TGAlib.cpp \ TGAlib.cpp \
TransformUtils.cpp \ TransformUtils.cpp \
ZipUtils.cpp \ ZipUtils.cpp \
platform/CCEGLViewProtocol.cpp \ platform/CCGLViewProtocol.cpp \
platform/CCFileUtils.cpp \ platform/CCFileUtils.cpp \
platform/CCSAXParser.cpp \ platform/CCSAXParser.cpp \
platform/CCThread.cpp \ platform/CCThread.cpp \

View File

@ -75,7 +75,7 @@ bool Configuration::init()
_valueDict["cocos2d.x.compiled_with_gl_state_cache"] = Value(true); _valueDict["cocos2d.x.compiled_with_gl_state_cache"] = Value(true);
#endif #endif
#ifdef DEBUG #if COCOS2D_DEBUG
_valueDict["cocos2d.x.build_type"] = Value("DEBUG"); _valueDict["cocos2d.x.build_type"] = Value("DEBUG");
#else #else
_valueDict["cocos2d.x.build_type"] = Value("RELEASE"); _valueDict["cocos2d.x.build_type"] = Value("RELEASE");

View File

@ -764,7 +764,7 @@ CC_DEPRECATED_ATTRIBUTE typedef TMXTiledMap CCTMXTiledMap;
CC_DEPRECATED_ATTRIBUTE typedef TileMapAtlas CCTileMapAtlas; CC_DEPRECATED_ATTRIBUTE typedef TileMapAtlas CCTileMapAtlas;
CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer; CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer;
CC_DEPRECATED_ATTRIBUTE typedef Scheduler CCScheduler; CC_DEPRECATED_ATTRIBUTE typedef Scheduler CCScheduler;
CC_DEPRECATED_ATTRIBUTE typedef EGLView CCEGLView; CC_DEPRECATED_ATTRIBUTE typedef GLView CCEGLView;
CC_DEPRECATED_ATTRIBUTE typedef Component CCComponent; CC_DEPRECATED_ATTRIBUTE typedef Component CCComponent;
CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform; CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform;
@ -840,7 +840,7 @@ CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameColor;
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition; CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition;
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord; CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord;
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_None = GL::VERTEX_ATTRIB_FLAT_NONE; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_None = GL::VERTEX_ATTRIB_FLAG_NONE;
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Position = GL::VERTEX_ATTRIB_FLAG_POSITION; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Position = GL::VERTEX_ATTRIB_FLAG_POSITION;
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Color = GL::VERTEX_ATTRIB_FLAG_COLOR; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Color = GL::VERTEX_ATTRIB_FLAG_COLOR;
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_TexCoords = GL::VERTEX_ATTRIB_FLAG_TEX_COORDS; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_TexCoords = GL::VERTEX_ATTRIB_FLAG_TEX_COORDS;

View File

@ -55,7 +55,7 @@ THE SOFTWARE.
#include "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"
#include "CCProfiling.h" #include "CCProfiling.h"
#include "platform/CCImage.h" #include "platform/CCImage.h"
#include "CCEGLView.h" #include "CCGLView.h"
#include "CCConfiguration.h" #include "CCConfiguration.h"
#include "CCEventDispatcher.h" #include "CCEventDispatcher.h"
#include "CCEventCustom.h" #include "CCEventCustom.h"
@ -351,7 +351,7 @@ void Director::calculateDeltaTime()
_deltaTime = MAX(0, _deltaTime); _deltaTime = MAX(0, _deltaTime);
} }
#ifdef DEBUG #if COCOS2D_DEBUG
// If we are debugging our code, prevent big delta time // If we are debugging our code, prevent big delta time
if (_deltaTime > 0.2f) if (_deltaTime > 0.2f)
{ {
@ -365,7 +365,7 @@ float Director::getDeltaTime() const
{ {
return _deltaTime; return _deltaTime;
} }
void Director::setOpenGLView(EGLView *openGLView) void Director::setOpenGLView(GLView *openGLView)
{ {
CCASSERT(openGLView, "opengl view should not be null"); CCASSERT(openGLView, "opengl view should not be null");
@ -376,9 +376,10 @@ void Director::setOpenGLView(EGLView *openGLView)
conf->gatherGPUInfo(); conf->gatherGPUInfo();
CCLOG("%s\n",conf->getInfo().c_str()); CCLOG("%s\n",conf->getInfo().c_str());
// EAGLView is not a Object if(_openGLView)
delete _openGLView; // [openGLView_ release] _openGLView->release();
_openGLView = openGLView; _openGLView = openGLView;
_openGLView->retain();
// set size // set size
_winSizeInPoints = _openGLView->getDesignResolutionSize(); _winSizeInPoints = _openGLView->getDesignResolutionSize();
@ -941,7 +942,8 @@ void Director::createStatsLabel()
Secondly, the size of this image is 480*320, to display the FPS label with correct size, Secondly, the size of this image is 480*320, to display the FPS label with correct size,
a factor of design resolution ratio of 480x320 is also needed. a factor of design resolution ratio of 480x320 is also needed.
*/ */
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f; auto glview = Director::getInstance()->getOpenGLView();
float factor = glview->getDesignResolutionSize().height / 320.0f;
_FPSLabel = LabelAtlas::create(); _FPSLabel = LabelAtlas::create();
_FPSLabel->retain(); _FPSLabel->retain();

View File

@ -49,7 +49,7 @@ NS_CC_BEGIN
/* Forward declarations. */ /* Forward declarations. */
class LabelAtlas; class LabelAtlas;
class Scene; class Scene;
class EGLView; class GLView;
class DirectorDelegate; class DirectorDelegate;
class Node; class Node;
class Scheduler; class Scheduler;
@ -143,12 +143,12 @@ public:
/** seconds per frame */ /** seconds per frame */
inline float getSecondsPerFrame() { return _secondsPerFrame; } inline float getSecondsPerFrame() { return _secondsPerFrame; }
/** Get the EGLView, where everything is rendered /** Get the GLView, where everything is rendered
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
inline EGLView* getOpenGLView() { return _openGLView; } inline GLView* getOpenGLView() { return _openGLView; }
void setOpenGLView(EGLView *openGLView); void setOpenGLView(GLView *openGLView);
TextureCache* getTextureCache() const; TextureCache* getTextureCache() const;
@ -202,7 +202,7 @@ public:
/** returns visible size of the OpenGL view in points. /** returns visible size of the OpenGL view in points.
* the value is equal to getWinSize if don't invoke * the value is equal to getWinSize if don't invoke
* EGLView::setDesignResolutionSize() * GLView::setDesignResolutionSize()
*/ */
Size getVisibleSize() const; Size getVisibleSize() const;
@ -422,8 +422,8 @@ protected:
/* delta time since last tick to main loop */ /* delta time since last tick to main loop */
float _deltaTime; float _deltaTime;
/* The EGLView, where everything is rendered */ /* The GLView, where everything is rendered */
EGLView *_openGLView; GLView *_openGLView;
//texture cache belongs to this director //texture cache belongs to this director
TextureCache *_textureCache; TextureCache *_textureCache;
@ -492,8 +492,8 @@ protected:
/* Console for the director */ /* Console for the director */
Console *_console; Console *_console;
// EGLViewProtocol will recreate stats labels to fit visible rect // GLViewProtocol will recreate stats labels to fit visible rect
friend class EGLViewProtocol; friend class GLViewProtocol;
}; };
/** /**

View File

@ -815,7 +815,7 @@ void EventDispatcher::dispatchTouchEvent(EventTouch* event)
if (event->isStopped()) if (event->isStopped())
{ {
updateListeners(event); updateListeners(event);
return false; return true;
} }
return false; return false;

View File

@ -60,7 +60,7 @@ private:
EventCode _eventCode; EventCode _eventCode;
std::vector<Touch*> _touches; std::vector<Touch*> _touches;
friend class EGLViewProtocol; friend class GLViewProtocol;
}; };

View File

@ -85,6 +85,7 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
break; break;
} }
_usedGlyphs = glyphs;
} }
const char * Font::getCurrentGlyphCollection() const const char * Font::getCurrentGlyphCollection() const
@ -99,7 +100,7 @@ const char * Font::getCurrentGlyphCollection() const
} }
} }
unsigned short int * Font::getUTF16Text(const char *text, int &outNumLetters) const unsigned short* Font::getUTF16Text(const char *text, int &outNumLetters) const
{ {
unsigned short* utf16String = cc_utf8_to_utf16(text); unsigned short* utf16String = cc_utf8_to_utf16(text);
@ -115,7 +116,7 @@ int Font::getUTF16TextLenght(unsigned short int *text) const
return cc_wcslen(text); return cc_wcslen(text);
} }
unsigned short int * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const unsigned short * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const
{ {
if ( newBegin < 0 || newEnd <= 0 ) if ( newBegin < 0 || newEnd <= 0 )
return 0; return 0;

View File

@ -49,8 +49,8 @@ public:
virtual int getFontMaxHeight() const { return 0; } virtual int getFontMaxHeight() const { return 0; }
virtual int getUTF16TextLenght(unsigned short int *text) const; virtual int getUTF16TextLenght(unsigned short int *text) const;
virtual unsigned short int * getUTF16Text(const char *text, int &outNumLetters) const; virtual unsigned short * getUTF16Text(const char *text, int &outNumLetters) const;
virtual unsigned short int * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const; virtual unsigned short * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const;
protected: protected:

View File

@ -152,7 +152,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
tempDef.width = tempRect.size.width + _letterPadding; tempDef.width = tempRect.size.width + _letterPadding;
tempDef.height = tempRect.size.height + _letterPadding; tempDef.height = tempRect.size.height + _letterPadding;
tempDef.offsetX = tempRect.origin.x + offsetAdjust; tempDef.offsetX = tempRect.origin.x + offsetAdjust;
tempDef.offsetY = tempRect.origin.y - offsetAdjust; tempDef.offsetY = _commonLineHeight + tempRect.origin.y - offsetAdjust;
} }
fontDefs[utf16String[i]] = tempDef; fontDefs[utf16String[i]] = tempDef;
} }

View File

@ -136,7 +136,9 @@ FontAtlas * FontFreeType::createFontAtlas()
FontAtlas *atlas = new FontAtlas(*this); FontAtlas *atlas = new FontAtlas(*this);
if (_usedGlyphs != GlyphCollection::DYNAMIC) if (_usedGlyphs != GlyphCollection::DYNAMIC)
{ {
atlas->prepareLetterDefinitions(cc_utf8_to_utf16(getCurrentGlyphCollection())); unsigned short* utf16 = cc_utf8_to_utf16(getCurrentGlyphCollection());
atlas->prepareLetterDefinitions(utf16);
CC_SAFE_DELETE_ARRAY(utf16);
} }
this->release(); this->release();
return atlas; return atlas;

View File

@ -197,7 +197,7 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,b
, _originalUTF16String(nullptr) , _originalUTF16String(nullptr)
, _horizontalKernings(nullptr) , _horizontalKernings(nullptr)
, _fontAtlas(atlas) , _fontAtlas(atlas)
, _isOpacityModifyRGB(true) , _isOpacityModifyRGB(false)
, _useDistanceField(useDistanceField) , _useDistanceField(useDistanceField)
, _useA8Shader(useA8Shader) , _useA8Shader(useA8Shader)
, _fontSize(0) , _fontSize(0)
@ -471,6 +471,8 @@ void Label::alignText()
insertQuadFromSprite(_reusedLetter,vaildIndex++); insertQuadFromSprite(_reusedLetter,vaildIndex++);
} }
} }
updateColor();
} }
bool Label::computeHorizontalKernings(unsigned short int *stringToRender) bool Label::computeHorizontalKernings(unsigned short int *stringToRender)

View File

@ -335,7 +335,14 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
// If the last character processed has an xAdvance which is less that the width of the characters image, then we need // If the last character processed has an xAdvance which is less that the width of the characters image, then we need
// to adjust the width of the string to take this into account, or the character will overlap the end of the bounding // to adjust the width of the string to take this into account, or the character will overlap the end of the bounding
// box // box
tmpSize.width = longestLine - charAdvance + lastCharWidth; if(charAdvance < lastCharWidth)
{
tmpSize.width = longestLine - charAdvance + lastCharWidth;
}
else
{
tmpSize.width = longestLine;
}
tmpSize.height = totalHeight; tmpSize.height = totalHeight;
theLabel->setContentSize(CC_SIZE_PIXELS_TO_POINTS(tmpSize)); theLabel->setContentSize(CC_SIZE_PIXELS_TO_POINTS(tmpSize));

View File

@ -290,7 +290,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type)
break; break;
case kShaderType_PositionTextureColorAlphaTest: case kShaderType_PositionTextureColorAlphaTest:
p->initWithVertexShaderByteArray(ccPositionTextureColor_noMVP_vert, ccPositionTextureColorAlphaTest_frag); p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag);
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);

View File

@ -250,8 +250,9 @@ public:
inline void setStoringCharacters(bool storingCharacters) { _storingCharacters = storingCharacters; }; inline void setStoringCharacters(bool storingCharacters) { _storingCharacters = storingCharacters; };
/// properties /// properties
inline ValueMap getProperties() const { return _properties; }; inline const ValueMap& getProperties() const { return _properties; }
inline void setProperties(ValueMap properties) { inline ValueMap& getProperties() { return _properties; }
inline void setProperties(const ValueMap& properties) {
_properties = properties; _properties = properties;
}; };

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#include "CCTextFieldTTF.h" #include "CCTextFieldTTF.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "CCEGLView.h" #include "CCGLView.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -126,7 +126,7 @@ bool TextFieldTTF::attachWithIME()
if (ret) if (ret)
{ {
// open keyboard // open keyboard
EGLView * pGlView = Director::getInstance()->getOpenGLView(); GLView * pGlView = Director::getInstance()->getOpenGLView();
if (pGlView) if (pGlView)
{ {
pGlView->setIMEKeyboardState(true); pGlView->setIMEKeyboardState(true);
@ -141,7 +141,7 @@ bool TextFieldTTF::detachWithIME()
if (ret) if (ret)
{ {
// close keyboard // close keyboard
EGLView * glView = Director::getInstance()->getOpenGLView(); GLView * glView = Director::getInstance()->getOpenGLView();
if (glView) if (glView)
{ {
glView->setIMEKeyboardState(false); glView->setIMEKeyboardState(false);

View File

@ -7,7 +7,7 @@ set(PLATFORM_SRC
platform/win32/CCFileUtilsWin32.cpp platform/win32/CCFileUtilsWin32.cpp
platform/win32/CCCommon.cpp platform/win32/CCCommon.cpp
platform/win32/CCApplication.cpp platform/win32/CCApplication.cpp
platform/win32/CCEGLView.cpp platform/win32/CCGLView.cpp
platform/win32/CCImage.cpp platform/win32/CCImage.cpp
platform/win32/CCDevice.cpp platform/win32/CCDevice.cpp
) )
@ -21,7 +21,7 @@ set(PLATFORM_SRC
platform/linux/CCFileUtilsLinux.cpp platform/linux/CCFileUtilsLinux.cpp
platform/linux/CCCommon.cpp platform/linux/CCCommon.cpp
platform/linux/CCApplication.cpp platform/linux/CCApplication.cpp
platform/desktop/CCEGLView.cpp platform/desktop/CCGLView.cpp
platform/linux/CCImage.cpp platform/linux/CCImage.cpp
platform/linux/CCDevice.cpp platform/linux/CCDevice.cpp
) )
@ -134,7 +134,7 @@ set(COCOS2D_SRC
CCDeprecated.cpp CCDeprecated.cpp
platform/CCSAXParser.cpp platform/CCSAXParser.cpp
platform/CCThread.cpp platform/CCThread.cpp
platform/CCEGLViewProtocol.cpp platform/CCGLViewProtocol.cpp
platform/CCFileUtils.cpp platform/CCFileUtils.cpp
../../external/edtaa3func/edtaa3func.cpp ../../external/edtaa3func/edtaa3func.cpp
renderer/CCCustomCommand.cpp renderer/CCCustomCommand.cpp

View File

@ -44,7 +44,7 @@ namespace GL {
/** vertex attrib flags */ /** vertex attrib flags */
enum { enum {
VERTEX_ATTRIB_FLAT_NONE = 0, VERTEX_ATTRIB_FLAG_NONE = 0,
VERTEX_ATTRIB_FLAG_POSITION = 1 << 0, VERTEX_ATTRIB_FLAG_POSITION = 1 << 0,
VERTEX_ATTRIB_FLAG_COLOR = 1 << 1, VERTEX_ATTRIB_FLAG_COLOR = 1 << 1,

View File

@ -107,9 +107,9 @@ Color4B::Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a)
{} {}
Color4B::Color4B(const Color3B& color) Color4B::Color4B(const Color3B& color)
: r(color.r * 255) : r(color.r)
, g(color.g * 255) , g(color.g)
, b(color.b * 255) , b(color.b)
, a(255) , a(255)
{} {}

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion() const char* cocos2dVersion()
{ {
return "3.0-beta"; return "3.0-beta2";
} }
NS_CC_END NS_CC_END

View File

@ -154,42 +154,42 @@ THE SOFTWARE.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "platform/ios/CCApplication.h" #include "platform/ios/CCApplication.h"
#include "platform/ios/CCEGLView.h" #include "platform/ios/CCGLView.h"
#include "platform/ios/CCGL.h" #include "platform/ios/CCGL.h"
#include "platform/ios/CCStdC.h" #include "platform/ios/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS #endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/CCApplication.h" #include "platform/android/CCApplication.h"
#include "platform/android/CCEGLView.h" #include "platform/android/CCGLView.h"
#include "platform/android/CCGL.h" #include "platform/android/CCGL.h"
#include "platform/android/CCStdC.h" #include "platform/android/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) #if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
#include "platform/blackberry/CCApplication.h" #include "platform/blackberry/CCApplication.h"
#include "platform/blackberry/CCEGLView.h" #include "platform/blackberry/CCGLView.h"
#include "platform/blackberry/CCGL.h" #include "platform/blackberry/CCGL.h"
#include "platform/blackberry/CCStdC.h" #include "platform/blackberry/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY #endif // CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "platform/win32/CCApplication.h" #include "platform/win32/CCApplication.h"
#include "platform/desktop/CCEGLView.h" #include "platform/desktop/CCGLView.h"
#include "platform/win32/CCGL.h" #include "platform/win32/CCGL.h"
#include "platform/win32/CCStdC.h" #include "platform/win32/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
#include "platform/mac/CCApplication.h" #include "platform/mac/CCApplication.h"
#include "platform/desktop/CCEGLView.h" #include "platform/desktop/CCGLView.h"
#include "platform/mac/CCGL.h" #include "platform/mac/CCGL.h"
#include "platform/mac/CCStdC.h" #include "platform/mac/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC #endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) #if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
#include "platform/linux/CCApplication.h" #include "platform/linux/CCApplication.h"
#include "platform/desktop/CCEGLView.h" #include "platform/desktop/CCGLView.h"
#include "platform/linux/CCGL.h" #include "platform/linux/CCGL.h"
#include "platform/linux/CCStdC.h" #include "platform/linux/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX #endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -304,11 +304,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="ccUtils.cpp" /> <ClCompile Include="ccUtils.cpp" />
<ClCompile Include="CCVertex.cpp" /> <ClCompile Include="CCVertex.cpp" />
<ClCompile Include="cocos2d.cpp" /> <ClCompile Include="cocos2d.cpp" />
<ClCompile Include="platform\CCEGLViewProtocol.cpp" /> <ClCompile Include="platform\CCGLViewProtocol.cpp" />
<ClCompile Include="platform\CCFileUtils.cpp" /> <ClCompile Include="platform\CCFileUtils.cpp" />
<ClCompile Include="platform\CCSAXParser.cpp" /> <ClCompile Include="platform\CCSAXParser.cpp" />
<ClCompile Include="platform\CCThread.cpp" /> <ClCompile Include="platform\CCThread.cpp" />
<ClCompile Include="platform\desktop\CCEGLView.cpp" /> <ClCompile Include="platform\desktop\CCGLView.cpp" />
<ClCompile Include="platform\win32\CCApplication.cpp" /> <ClCompile Include="platform\win32\CCApplication.cpp" />
<ClCompile Include="platform\win32\CCCommon.cpp" /> <ClCompile Include="platform\win32\CCCommon.cpp" />
<ClCompile Include="platform\win32\CCDevice.cpp" /> <ClCompile Include="platform\win32\CCDevice.cpp" />
@ -505,13 +505,13 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClInclude Include="platform\CCApplicationProtocol.h" /> <ClInclude Include="platform\CCApplicationProtocol.h" />
<ClInclude Include="platform\CCCommon.h" /> <ClInclude Include="platform\CCCommon.h" />
<ClInclude Include="platform\CCDevice.h" /> <ClInclude Include="platform\CCDevice.h" />
<ClInclude Include="platform\CCEGLViewProtocol.h" /> <ClInclude Include="platform\CCGLViewProtocol.h" />
<ClInclude Include="platform\CCFileUtils.h" /> <ClInclude Include="platform\CCFileUtils.h" />
<ClInclude Include="platform\CCImage.h" /> <ClInclude Include="platform\CCImage.h" />
<ClInclude Include="platform\CCImageCommon_cpp.h" /> <ClInclude Include="platform\CCImageCommon_cpp.h" />
<ClInclude Include="platform\CCSAXParser.h" /> <ClInclude Include="platform\CCSAXParser.h" />
<ClInclude Include="platform\CCThread.h" /> <ClInclude Include="platform\CCThread.h" />
<ClInclude Include="platform\desktop\CCEGLView.h" /> <ClInclude Include="platform\desktop\CCGLView.h" />
<ClInclude Include="platform\win32\CCApplication.h" /> <ClInclude Include="platform\win32\CCApplication.h" />
<ClInclude Include="platform\win32\CCFileUtilsWin32.h" /> <ClInclude Include="platform\win32\CCFileUtilsWin32.h" />
<ClInclude Include="platform\win32\CCGL.h" /> <ClInclude Include="platform\win32\CCGL.h" />

View File

@ -363,7 +363,7 @@
<ClCompile Include="platform\win32\CCStdC.cpp"> <ClCompile Include="platform\win32\CCStdC.cpp">
<Filter>platform\win32</Filter> <Filter>platform\win32</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="platform\CCEGLViewProtocol.cpp"> <ClCompile Include="platform\CCGLViewProtocol.cpp">
<Filter>platform</Filter> <Filter>platform</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="platform\CCFileUtils.cpp"> <ClCompile Include="platform\CCFileUtils.cpp">
@ -595,7 +595,7 @@
<ClCompile Include="CCFontCharMap.cpp"> <ClCompile Include="CCFontCharMap.cpp">
<Filter>label_nodes</Filter> <Filter>label_nodes</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="platform\desktop\CCEGLView.cpp"> <ClCompile Include="platform\desktop\CCGLView.cpp">
<Filter>platform\desktop</Filter> <Filter>platform\desktop</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@ -876,7 +876,7 @@
<ClInclude Include="platform\CCDevice.h"> <ClInclude Include="platform\CCDevice.h">
<Filter>platform</Filter> <Filter>platform</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="platform\CCEGLViewProtocol.h"> <ClInclude Include="platform\CCGLViewProtocol.h">
<Filter>platform</Filter> <Filter>platform</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="platform\CCFileUtils.h"> <ClInclude Include="platform\CCFileUtils.h">
@ -1198,7 +1198,7 @@
<ClInclude Include="CCFontCharMap.h"> <ClInclude Include="CCFontCharMap.h">
<Filter>label_nodes</Filter> <Filter>label_nodes</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="platform\desktop\CCEGLView.h"> <ClInclude Include="platform\desktop\CCGLView.h">
<Filter>platform\desktop</Filter> <Filter>platform\desktop</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>

View File

@ -1,149 +0,0 @@
################################################################################
#
# LINUX MAKEFILE
#
# Available options are:
# - CLANG=1 : Compiles with clang instead of gcc. Clang must be in your PATH.
# - V=1 : Enables the verbose mode.
# - DEBUG=1 : Enables the debug mode, disable compiler optimizations.
# - OPENAL=1 : Uses OpenAL instead of FMOD as sound engine.
#
################################################################################
all:
# Remove -Wall, because it enables -Wunused-function, and this warning exists in webp.h
# when enable c++11. I don't know why.
# GCC 4.6 is primary platform for cocos2d v.3, because it's default compiler for Android,
# Blackberry, some Linux distributions.It supports all important features of c++11, but have
# no flag "-std=c++11" (which was turned on in version 4.7).
CCFLAGS += -MMD -Wno-deprecated-declarations -fPIC
CXXFLAGS += -MMD -Wno-deprecated-declarations -fPIC -std=gnu++0x
ifeq ($(CLANG), 1)
CC := clang
CXX := clang++
DEFINES += -D__STRICT_ANSI__ # Allows clang 3.3 to use __float128
else
CC = gcc
CXX = g++
CCFLAGS += -Werror
CXXFLAGS += -Werror
endif
ARFLAGS = cr
DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
ifdef USE_BOX2D
DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1
else
DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
endif
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ifndef COCOS_ROOT
COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..)
endif
COCOS_SRC = $(COCOS_ROOT)/cocos/2d
OBJ_DIR ?= obj
LIB_DIR = $(COCOS_ROOT)/lib/linux
BIN_DIR = bin
INCLUDES += \
-I$(COCOS_SRC)/ \
-I$(COCOS_SRC)/../math/kazmath/include \
-I$(COCOS_SRC)/platform/linux \
-I$(COCOS_SRC)/../../external/jpeg/include/linux \
-I$(COCOS_SRC)/../../external/tiff/include/linux \
-I$(COCOS_SRC)/../../external/webp/include/linux \
-I$(COCOS_SRC)/../../external/tinyxml2 \
-I$(COCOS_SRC)/../../external/unzip \
-I$(COCOS_SRC)/../../external/glfw3/include/linux \
-I$(COCOS_SRC)/../physics \
-I$(COCOS_SRC)/../base \
-I$(COCOS_SRC)/../../external/chipmunk/include/chipmunk \
-I$(COCOS_SRC)/../../external/freetype2/include/linux \
-I$(COCOS_SRC)/../.. \
-I$(COCOS_SRC)/../audio/include
LBITS := $(shell getconf LONG_BIT)
ifeq ($(DEBUG), 1)
CCFLAGS += -g3 -O0
CXXFLAGS += -g3 -O0
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1
OBJ_DIR := $(OBJ_DIR)/debug
LIB_DIR := $(LIB_DIR)/debug
BIN_DIR := $(BIN_DIR)/debug
else
CCFLAGS += -O3
CXXFLAGS += -O3
DEFINES += -DNDEBUG
OBJ_DIR := $(OBJ_DIR)/release
LIB_DIR := $(LIB_DIR)/release
BIN_DIR := $(BIN_DIR)/release
endif
ifndef V
LOG_CC = @echo " CC $@";
LOG_CXX = @echo " CXX $@";
LOG_AR = @echo " AR $@";
LOG_LINK = @echo " LINK $@";
endif
OBJECTS := $(SOURCES:.cpp=.o)
OBJECTS := $(OBJECTS:.c=.o)
OBJECTS := $(subst ../,,$(OBJECTS))
OBJECTS := $(subst $(COCOS_ROOT)/,,$(OBJECTS))
OBJECTS := $(addprefix $(OBJ_DIR)/, $(OBJECTS))
DEPS = $(OBJECTS:.o=.d)
CORE_MAKEFILE_LIST := $(MAKEFILE_LIST)
-include $(DEPS)
STATICLIBS_DIR = $(COCOS_ROOT)/external
ifeq ($(LBITS),64)
POSTFIX = 64-bit
else
POSTFIX = 32-bit
endif
STATICLIBS = $(STATICLIBS_DIR)/freetype2/prebuilt/linux/$(POSTFIX)/libfreetype.a \
$(STATICLIBS_DIR)/jpeg/prebuilt/linux/$(POSTFIX)/libjpeg.a \
$(STATICLIBS_DIR)/tiff/prebuilt/linux/$(POSTFIX)/libtiff.a \
$(STATICLIBS_DIR)/webp/prebuilt/linux/$(POSTFIX)/libwebp.a
ifneq ($(OPENAL),1)
ifeq ($(LBITS),64)
FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/lib64/api/lib
SHAREDLIBS += -lfmodex64
else
FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/api/lib
SHAREDLIBS += -lfmodex
endif
endif
SHAREDLIBS += -lGLEW -lfontconfig -lpthread -lGL -lpng `pkg-config --libs glfw3`
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))
LIBS = -lrt -lz -lX11
clean:
rm -rf $(OBJ_DIR)
rm -f $(TARGET) core
.PHONY: all clean
# If the parent Makefile defines $(EXECUTABLE) then define this as the target
# and create a 'make run' rule to run the app.
ifdef EXECUTABLE
TARGET := $(BIN_DIR)/$(EXECUTABLE)
all: $(TARGET)
run: $(TARGET)
cd $(dir $^) && ./$(notdir $^)
.PHONY: run
endif

View File

@ -33,6 +33,8 @@ NS_CC_BEGIN
* @{ * @{
*/ */
class EAGLView;
class CC_DLL ApplicationProtocol class CC_DLL ApplicationProtocol
{ {
public: public:

View File

@ -56,6 +56,7 @@ enum class LanguageType
ITALIAN, ITALIAN,
GERMAN, GERMAN,
SPANISH, SPANISH,
DUTCH,
RUSSIAN, RUSSIAN,
KOREAN, KOREAN,
JAPANESE, JAPANESE,

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCEGLViewProtocol.h" #include "CCGLViewProtocol.h"
#include "CCTouch.h" #include "CCTouch.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "CCSet.h" #include "CCSet.h"
@ -71,24 +71,23 @@ namespace {
} }
EGLViewProtocol::EGLViewProtocol() GLViewProtocol::GLViewProtocol()
: _delegate(nullptr) : _scaleX(1.0f)
, _scaleX(1.0f)
, _scaleY(1.0f) , _scaleY(1.0f)
, _resolutionPolicy(ResolutionPolicy::UNKNOWN) , _resolutionPolicy(ResolutionPolicy::UNKNOWN)
{ {
} }
EGLViewProtocol::~EGLViewProtocol() GLViewProtocol::~GLViewProtocol()
{ {
} }
void EGLViewProtocol::pollInputEvents() void GLViewProtocol::pollInputEvents()
{ {
} }
void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy) void GLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
{ {
CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy"); CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy");
@ -107,17 +106,17 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut
_scaleX = _scaleY = MAX(_scaleX, _scaleY); _scaleX = _scaleY = MAX(_scaleX, _scaleY);
} }
if (resolutionPolicy == ResolutionPolicy::SHOW_ALL) else if (resolutionPolicy == ResolutionPolicy::SHOW_ALL)
{ {
_scaleX = _scaleY = MIN(_scaleX, _scaleY); _scaleX = _scaleY = MIN(_scaleX, _scaleY);
} }
if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) { else if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
_scaleX = _scaleY; _scaleX = _scaleY;
_designResolutionSize.width = ceilf(_screenSize.width/_scaleX); _designResolutionSize.width = ceilf(_screenSize.width/_scaleX);
} }
if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) { else if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
_scaleY = _scaleX; _scaleY = _scaleX;
_designResolutionSize.height = ceilf(_screenSize.height/_scaleY); _designResolutionSize.height = ceilf(_screenSize.height/_scaleY);
} }
@ -131,27 +130,36 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut
_resolutionPolicy = resolutionPolicy; _resolutionPolicy = resolutionPolicy;
// reset director's member variables to fit visible rect // reset director's member variables to fit visible rect
Director::getInstance()->_winSizeInPoints = getDesignResolutionSize(); auto director = Director::getInstance();
Director::getInstance()->createStatsLabel(); director->_winSizeInPoints = getDesignResolutionSize();
Director::getInstance()->setGLDefaultValues(); director->createStatsLabel();
director->setGLDefaultValues();
} }
const Size& EGLViewProtocol::getDesignResolutionSize() const const Size& GLViewProtocol::getDesignResolutionSize() const
{ {
return _designResolutionSize; return _designResolutionSize;
} }
const Size& EGLViewProtocol::getFrameSize() const const Size& GLViewProtocol::getFrameSize() const
{ {
return _screenSize; return _screenSize;
} }
void EGLViewProtocol::setFrameSize(float width, float height) void GLViewProtocol::setFrameSize(float width, float height)
{ {
_designResolutionSize = _screenSize = Size(width, height); _designResolutionSize = _screenSize = Size(width, height);
} }
Size EGLViewProtocol::getVisibleSize() const Rect GLViewProtocol::getVisibleRect() const
{
Rect ret;
ret.size = getVisibleSize();
ret.origin = getVisibleOrigin();
return ret;
}
Size GLViewProtocol::getVisibleSize() const
{ {
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
{ {
@ -163,7 +171,7 @@ Size EGLViewProtocol::getVisibleSize() const
} }
} }
Point EGLViewProtocol::getVisibleOrigin() const Point GLViewProtocol::getVisibleOrigin() const
{ {
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
{ {
@ -176,12 +184,7 @@ Point EGLViewProtocol::getVisibleOrigin() const
} }
} }
void EGLViewProtocol::setTouchDelegate(EGLTouchDelegate * delegate) void GLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
{
_delegate = delegate;
}
void EGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
{ {
glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x), glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x),
(GLint)(y * _scaleY + _viewPortRect.origin.y), (GLint)(y * _scaleY + _viewPortRect.origin.y),
@ -189,7 +192,7 @@ void EGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
(GLsizei)(h * _scaleY)); (GLsizei)(h * _scaleY));
} }
void EGLViewProtocol::setScissorInPoints(float x , float y , float w , float h) void GLViewProtocol::setScissorInPoints(float x , float y , float w , float h)
{ {
glScissor((GLint)(x * _scaleX + _viewPortRect.origin.x), glScissor((GLint)(x * _scaleX + _viewPortRect.origin.x),
(GLint)(y * _scaleY + _viewPortRect.origin.y), (GLint)(y * _scaleY + _viewPortRect.origin.y),
@ -197,12 +200,12 @@ void EGLViewProtocol::setScissorInPoints(float x , float y , float w , float h)
(GLsizei)(h * _scaleY)); (GLsizei)(h * _scaleY));
} }
bool EGLViewProtocol::isScissorEnabled() bool GLViewProtocol::isScissorEnabled()
{ {
return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true; return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true;
} }
Rect EGLViewProtocol::getScissorRect() const Rect GLViewProtocol::getScissorRect() const
{ {
GLfloat params[4]; GLfloat params[4];
glGetFloatv(GL_SCISSOR_BOX, params); glGetFloatv(GL_SCISSOR_BOX, params);
@ -213,17 +216,17 @@ Rect EGLViewProtocol::getScissorRect() const
return Rect(x, y, w, h); return Rect(x, y, w, h);
} }
void EGLViewProtocol::setViewName(const std::string& viewname ) void GLViewProtocol::setViewName(const std::string& viewname )
{ {
_viewName = viewname; _viewName = viewname;
} }
const std::string& EGLViewProtocol::getViewName() const const std::string& GLViewProtocol::getViewName() const
{ {
return _viewName; return _viewName;
} }
void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
{ {
int id = 0; int id = 0;
float x = 0.0f; float x = 0.0f;
@ -273,7 +276,7 @@ void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float y
dispatcher->dispatchEvent(&touchEvent); dispatcher->dispatchEvent(&touchEvent);
} }
void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[])
{ {
int id = 0; int id = 0;
float x = 0.0f; float x = 0.0f;
@ -321,7 +324,7 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
dispatcher->dispatchEvent(&touchEvent); dispatcher->dispatchEvent(&touchEvent);
} }
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[])
{ {
int id = 0; int id = 0;
float x = 0.0f; float x = 0.0f;
@ -381,27 +384,27 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
} }
} }
void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);
} }
void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);
} }
const Rect& EGLViewProtocol::getViewPortRect() const const Rect& GLViewProtocol::getViewPortRect() const
{ {
return _viewPortRect; return _viewPortRect;
} }
float EGLViewProtocol::getScaleX() const float GLViewProtocol::getScaleX() const
{ {
return _scaleX; return _scaleX;
} }
float EGLViewProtocol::getScaleY() const float GLViewProtocol::getScaleY() const
{ {
return _scaleY; return _scaleY;
} }

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __CCEGLVIEWPROTOCOL_H__ #ifndef __CCGLVIEWPROTOCOL_H__
#define __CCEGLVIEWPROTOCOL_H__ #define __CCGLVIEWPROTOCOL_H__
#include "ccTypes.h" #include "ccTypes.h"
#include "CCEventTouch.h" #include "CCEventTouch.h"
@ -65,30 +65,30 @@ class EGLTouchDelegate;
* @{ * @{
*/ */
class CC_DLL EGLViewProtocol class CC_DLL GLViewProtocol
{ {
public: public:
/** /**
* @js ctor * @js ctor
*/ */
EGLViewProtocol(); GLViewProtocol();
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual ~EGLViewProtocol(); virtual ~GLViewProtocol();
/** Force destroying EGL view, subclass must implement this method. */ /** Force destroying EGL view, subclass must implement this method. */
virtual void end() = 0; virtual void end() = 0;
/** Get whether opengl render system is ready, subclass must implement this method. */ /** Get whether opengl render system is ready, subclass must implement this method. */
virtual bool isOpenGLReady() = 0; virtual bool isOpenGLReady() = 0;
/** Exchanges the front and back buffers, subclass must implement this method. */ /** Exchanges the front and back buffers, subclass must implement this method. */
virtual void swapBuffers() = 0; virtual void swapBuffers() = 0;
/** Open or close IME keyboard , subclass must implement this method. */ /** Open or close IME keyboard , subclass must implement this method. */
virtual void setIMEKeyboardState(bool open) = 0; virtual void setIMEKeyboardState(bool open) = 0;
/** /**
* Polls input events. Subclass must implement methods if platform * Polls input events. Subclass must implement methods if platform
@ -117,6 +117,11 @@ public:
*/ */
virtual Point getVisibleOrigin() const; virtual Point getVisibleOrigin() const;
/**
* Get the visible rectangle of opengl viewport.
*/
virtual Rect getVisibleRect() const;
/** /**
* Set the design resolution size. * Set the design resolution size.
* @param width Design resolution width. * @param width Design resolution width.
@ -133,9 +138,6 @@ public:
*/ */
virtual const Size& getDesignResolutionSize() const; virtual const Size& getDesignResolutionSize() const;
/** Set touch delegate */
virtual void setTouchDelegate(EGLTouchDelegate * delegate);
/** /**
* Set opengl view port rectangle with points. * Set opengl view port rectangle with points.
*/ */
@ -180,12 +182,12 @@ public:
*/ */
float getScaleY() const; float getScaleY() const;
/** returns the current Resolution policy */
ResolutionPolicy getResolutionPolicy() const { return _resolutionPolicy; }
protected: protected:
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]); void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]);
EGLTouchDelegate* _delegate;
// real screen size // real screen size
Size _screenSize; Size _screenSize;
// resolution size, it is the size appropriate for the app resources. // resolution size, it is the size appropriate for the app resources.
@ -195,8 +197,8 @@ protected:
// the view name // the view name
std::string _viewName; std::string _viewName;
float _scaleX; float _scaleX;
float _scaleY; float _scaleY;
ResolutionPolicy _resolutionPolicy; ResolutionPolicy _resolutionPolicy;
}; };
@ -205,4 +207,4 @@ protected:
NS_CC_END NS_CC_END
#endif /* __CCEGLVIEWPROTOCOL_H__ */ #endif /* __CCGLVIEWPROTOCOL_H__ */

View File

@ -10,7 +10,7 @@ LOCAL_SRC_FILES := \
CCApplication.cpp \ CCApplication.cpp \
CCCommon.cpp \ CCCommon.cpp \
CCDevice.cpp \ CCDevice.cpp \
CCEGLView.cpp \ CCGLView.cpp \
CCFileUtilsAndroid.cpp \ CCFileUtilsAndroid.cpp \
CCImage.cpp \ CCImage.cpp \
nativeactivity.cpp \ nativeactivity.cpp \

View File

@ -22,11 +22,15 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "jni/JniHelper.h" #include "jni/JniHelper.h"
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#include "CCApplication.h" #include "CCApplication.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "CCEGLView.h" #include "CCGLView.h"
#include <android/log.h> #include <android/log.h>
#include <jni.h> #include <jni.h>
#include <cstring> #include <cstring>
@ -116,6 +120,10 @@ LanguageType Application::getCurrentLanguage()
{ {
ret = LanguageType::RUSSIAN; ret = LanguageType::RUSSIAN;
} }
else if (0 == strcmp("nl", pLanguageName))
{
ret = LanguageType::DUTCH;
}
else if (0 == strcmp("ko", pLanguageName)) else if (0 == strcmp("ko", pLanguageName))
{ {
ret = LanguageType::KOREAN; ret = LanguageType::KOREAN;
@ -157,3 +165,6 @@ void Application::applicationScreenSizeChanged(int newWidth, int newHeight) {
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -22,9 +22,13 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __CC_APPLICATION_ANDROID_H__ #ifndef __CC_APPLICATION_ANDROID_H__
#define __CC_APPLICATION_ANDROID_H__ #define __CC_APPLICATION_ANDROID_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "platform/CCApplicationProtocol.h" #include "platform/CCApplicationProtocol.h"
@ -87,4 +91,6 @@ protected:
NS_CC_END NS_CC_END
#endif // __CC_APPLICATION_ANDROID_H__ #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif // __CC_APPLICATION_ANDROID_H__

View File

@ -23,6 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#include <android/log.h> #include <android/log.h>
@ -44,3 +47,6 @@ void LuaLog(const char * pszFormat)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "platform/CCDevice.h" #include "platform/CCDevice.h"
#include "jni/DPIJni.h" #include "jni/DPIJni.h"
#include "nativeactivity.h" #include "nativeactivity.h"
@ -56,3 +60,6 @@ void Device::setAccelerometerInterval(float interval)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "CCFileUtilsAndroid.h" #include "CCFileUtilsAndroid.h"
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
@ -353,3 +357,5 @@ string FileUtilsAndroid::getWritablePath() const
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -25,6 +25,9 @@ Copyright (c) 2013-2014 Chukong Technologies Inc.
#ifndef __CC_FILEUTILS_ANDROID_H__ #ifndef __CC_FILEUTILS_ANDROID_H__
#define __CC_FILEUTILS_ANDROID_H__ #define __CC_FILEUTILS_ANDROID_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#include "ccTypes.h" #include "ccTypes.h"
@ -86,4 +89,6 @@ private:
NS_CC_END NS_CC_END
#endif // __CC_FILEUTILS_ANDROID_H__ #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif // __CC_FILEUTILS_ANDROID_H__

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CCGL_H__ #ifndef __CCGL_H__
#define __CCGL_H__ #define __CCGL_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#define glClearDepth glClearDepthf #define glClearDepth glClearDepthf
#define glDeleteVertexArrays glDeleteVertexArraysOES #define glDeleteVertexArrays glDeleteVertexArraysOES
#define glGenVertexArrays glGenVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES
@ -63,4 +66,6 @@ extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT;
#define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT #define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif // __CCGL_H__ #endif // __CCGL_H__

View File

@ -22,7 +22,11 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCEGLView.h"
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "CCGLView.h"
#include "CCSet.h" #include "CCSet.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "ccMacros.h" #include "ccMacros.h"
@ -48,46 +52,79 @@ void initExtensions() {
NS_CC_BEGIN NS_CC_BEGIN
EGLView::EGLView() GLView* GLView::createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
auto ret = new GLView;
if(ret && ret->initWithRect(viewName, rect, frameZoomFactor)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::create(const std::string& viewName)
{
auto ret = new GLView;
if(ret && ret->initWithFullScreen(viewName)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::createWithFullScreen(const std::string& viewName)
{
auto ret = new GLView();
if(ret && ret->initWithFullScreen(viewName)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView::GLView()
{ {
initExtensions(); initExtensions();
} }
EGLView::~EGLView() GLView::~GLView()
{ {
} }
bool EGLView::isOpenGLReady() bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
return true;
}
bool GLView::initWithFullScreen(const std::string& viewName)
{
return true;
}
bool GLView::isOpenGLReady()
{ {
return (_screenSize.width != 0 && _screenSize.height != 0); return (_screenSize.width != 0 && _screenSize.height != 0);
} }
void EGLView::end() void GLView::end()
{ {
terminateProcessJNI(); terminateProcessJNI();
} }
void EGLView::swapBuffers() void GLView::swapBuffers()
{ {
} }
EGLView* EGLView::getInstance() void GLView::setIMEKeyboardState(bool bOpen)
{
static EGLView instance;
return &instance;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
void EGLView::setIMEKeyboardState(bool bOpen)
{ {
setKeyboardStateJNI((int)bOpen); setKeyboardStateJNI((int)bOpen);
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -26,41 +26,40 @@ THE SOFTWARE.
#ifndef __CC_EGLVIEW_ANDROID_H__ #ifndef __CC_EGLVIEW_ANDROID_H__
#define __CC_EGLVIEW_ANDROID_H__ #define __CC_EGLVIEW_ANDROID_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "CCObject.h"
#include "CCGeometry.h" #include "CCGeometry.h"
#include "platform/CCEGLViewProtocol.h" #include "platform/CCGLViewProtocol.h"
NS_CC_BEGIN NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL GLView : public Object, public GLViewProtocol
{ {
public: public:
/**
* @js ctor
*/
EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView();
bool isOpenGLReady();
// keep compatible
void end();
void swapBuffers();
void setIMEKeyboardState(bool bOpen);
// static function // static function
/** static GLView* create(const std::string &viewname);
@brief get the shared main open gl window static GLView* createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor = 1.0f);
*/ static GLView* createWithFullScreen(const std::string& viewName);
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */ bool isOpenGLReady() override;
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); void end() override;
void swapBuffers() override;
void setIMEKeyboardState(bool bOpen) override;
protected:
GLView();
virtual ~GLView();
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);
bool initWithFullScreen(const std::string& viewName);
}; };
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif // end of __CC_EGLVIEW_ANDROID_H__ #endif // end of __CC_EGLVIEW_ANDROID_H__

View File

@ -23,7 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
//#define COCOS2D_DEBUG 1 #include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#define __CC_PLATFORM_IMAGE_CPP__ #define __CC_PLATFORM_IMAGE_CPP__
#include "platform/CCImageCommon_cpp.h" #include "platform/CCImageCommon_cpp.h"
@ -246,3 +247,5 @@ extern "C"
env->GetByteArrayRegion(pixels, 0, size, (jbyte*)bitmapDC._data); env->GetByteArrayRegion(pixels, 0, size, (jbyte*)bitmapDC._data);
} }
}; };
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CCPLATFORMDEFINE_H__ #ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "android/log.h" #include "android/log.h"
#define CC_DLL #define CC_DLL
@ -59,4 +62,6 @@ THE SOFTWARE.
#endif #endif
#endif #endif
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif /* __CCPLATFORMDEFINE_H__*/ #endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CC_STD_C_H__ #ifndef __CC_STD_C_H__
#define __CC_STD_C_H__ #define __CC_STD_C_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#include <float.h> #include <float.h>
#include <math.h> #include <math.h>
@ -45,4 +48,6 @@ THE SOFTWARE.
#define MAX(x,y) (((x) < (y)) ? (y) : (x)) #define MAX(x,y) (((x) < (y)) ? (y) : (x))
#endif // MAX #endif // MAX
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif // __CC_STD_C_H__ #endif // __CC_STD_C_H__

View File

@ -21,6 +21,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "nativeactivity.h" #include "nativeactivity.h"
#include <jni.h> #include <jni.h>
@ -43,7 +47,7 @@ THE SOFTWARE.
#include "CCFileUtilsAndroid.h" #include "CCFileUtilsAndroid.h"
#include "jni/JniHelper.h" #include "jni/JniHelper.h"
#include "CCEGLView.h" #include "CCGLView.h"
#include "CCDrawingPrimitives.h" #include "CCDrawingPrimitives.h"
#include "CCShaderCache.h" #include "CCShaderCache.h"
#include "CCTextureCache.h" #include "CCTextureCache.h"
@ -111,29 +115,27 @@ extern EditTextCallback s_pfEditTextCallback;
extern void* s_ctx; extern void* s_ctx;
extern "C" { extern "C" {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) {
jsize size = env->GetArrayLength(text); jsize size = env->GetArrayLength(text);
pthread_mutex_lock(&(engine.app->mutex)); pthread_mutex_lock(&(engine.app->mutex));
if (size > 0) { if (size > 0) {
jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0);
char* pBuf = (char*)malloc(size+1);
if (pBuf != NULL) {
memcpy(pBuf, data, size);
pBuf[size] = '\0';
editboxText = pBuf;
}
env->ReleaseByteArrayElements(text, data, 0);
} else {
jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0); char* pBuf = (char*)malloc(1);
char* pBuf = (char*)malloc(size+1); pBuf[0] = '\0';
if (pBuf != NULL) { editboxText = pBuf;
memcpy(pBuf, data, size); }
pBuf[size] = '\0'; pthread_cond_broadcast(&engine.app->cond);
editboxText = pBuf; pthread_mutex_unlock(&(engine.app->mutex));
} }
env->ReleaseByteArrayElements(text, data, 0);
} else {
char* pBuf = (char*)malloc(1);
pBuf[0] = '\0';
editboxText = pBuf;
}
pthread_cond_broadcast(&engine.app->cond);
pthread_mutex_unlock(&(engine.app->mutex));
}
} }
typedef struct cocos_dimensions { typedef struct cocos_dimensions {
@ -141,17 +143,21 @@ typedef struct cocos_dimensions {
int h; int h;
} cocos_dimensions; } cocos_dimensions;
static void cocos_init(cocos_dimensions d, struct android_app* app) { static void cocos_init(cocos_dimensions d, struct android_app* app)
{
LOGI("cocos_init(...)"); LOGI("cocos_init(...)");
pthread_t thisthread = pthread_self(); pthread_t thisthread = pthread_self();
LOGI("pthread_self() = %X", thisthread); LOGI("pthread_self() = %X", thisthread);
cocos2d::FileUtilsAndroid::setassetmanager(app->activity->assetManager); cocos2d::FileUtilsAndroid::setassetmanager(app->activity->assetManager);
if (!cocos2d::Director::getInstance()->getOpenGLView()) auto director = cocos2d::Director::getInstance();
auto glview = director->getOpenGLView();
if (!glview)
{ {
cocos2d::EGLView *view = cocos2d::EGLView::getInstance(); glview = cocos2d::GLView::create("Android app");
view->setFrameSize(d.w, d.h); glview->setFrameSize(d.w, d.h);
director->setOpenGLView(glview);
cocos_android_app_init(app); cocos_android_app_init(app);
@ -163,16 +169,18 @@ static void cocos_init(cocos_dimensions d, struct android_app* app) {
cocos2d::ShaderCache::getInstance()->reloadDefaultShaders(); cocos2d::ShaderCache::getInstance()->reloadDefaultShaders();
cocos2d::DrawPrimitives::init(); cocos2d::DrawPrimitives::init();
cocos2d::VolatileTextureMgr::reloadAllTextures(); cocos2d::VolatileTextureMgr::reloadAllTextures();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND); cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent); director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
cocos2d::Director::getInstance()->setGLDefaultValues(); director->setGLDefaultValues();
} }
} }
/** /**
* Initialize an EGL context for the current display. * Initialize an EGL context for the current display.
*/ */
static cocos_dimensions engine_init_display(struct engine* engine) { static cocos_dimensions engine_init_display(struct engine* engine)
{
cocos_dimensions r; cocos_dimensions r;
r.w = -1; r.w = -1;
r.h = -1; r.h = -1;
@ -245,6 +253,7 @@ static cocos_dimensions engine_init_display(struct engine* engine) {
r.w = w; r.w = w;
r.h = h; r.h = h;
return r; return r;
} }
@ -275,7 +284,8 @@ static void dispatch_pending_runnables() {
/** /**
* Just the current frame in the display. * Just the current frame in the display.
*/ */
static void engine_draw_frame(struct engine* engine) { static void engine_draw_frame(struct engine* engine)
{
LOG_RENDER_DEBUG("engine_draw_frame(...)"); LOG_RENDER_DEBUG("engine_draw_frame(...)");
pthread_t thisthread = pthread_self(); pthread_t thisthread = pthread_self();
LOG_RENDER_DEBUG("pthread_self() = %X", thisthread); LOG_RENDER_DEBUG("pthread_self() = %X", thisthread);
@ -295,12 +305,12 @@ static void engine_draw_frame(struct engine* engine) {
/* ((float)engine->state.y)/engine->height, 1); */ /* ((float)engine->state.y)/engine->height, 1); */
/* glClear(GL_COLOR_BUFFER_BIT); */ /* glClear(GL_COLOR_BUFFER_BIT); */
if (s_pfEditTextCallback && editboxText) if (s_pfEditTextCallback && editboxText)
{ {
s_pfEditTextCallback(editboxText, s_ctx); s_pfEditTextCallback(editboxText, s_ctx);
free(editboxText); free(editboxText);
editboxText = NULL; editboxText = NULL;
} }
eglSwapBuffers(engine->display, engine->surface); eglSwapBuffers(engine->display, engine->surface);
} }
@ -308,7 +318,8 @@ static void engine_draw_frame(struct engine* engine) {
/** /**
* Tear down the EGL context currently associated with the display. * Tear down the EGL context currently associated with the display.
*/ */
static void engine_term_display(struct engine* engine) { static void engine_term_display(struct engine* engine)
{
if (engine->display != EGL_NO_DISPLAY) { if (engine->display != EGL_NO_DISPLAY) {
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (engine->context != EGL_NO_CONTEXT) { if (engine->context != EGL_NO_CONTEXT) {
@ -390,7 +401,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
int ids[pointerCount]; int ids[pointerCount];
float xs[pointerCount], ys[pointerCount]; float xs[pointerCount], ys[pointerCount];
getTouchPos(event, ids, xs, ys); getTouchPos(event, ids, xs, ys);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys);
return 1; return 1;
} }
break; break;
@ -435,7 +446,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
int ids[pointerCount]; int ids[pointerCount];
float xs[pointerCount], ys[pointerCount]; float xs[pointerCount], ys[pointerCount];
getTouchPos(event, ids, xs, ys); getTouchPos(event, ids, xs, ys);
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys);
return 1; return 1;
} }
break; break;
@ -494,8 +505,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
return handle_touch_input(event); return handle_touch_input(event);
} }
else else
return handle_key_input(event); return handle_key_input(event);
return 0; return 0;
} }
@ -533,7 +544,8 @@ void setAccelerometerIntervalJni(float interval) {
/** /**
* Process the next main command. * Process the next main command.
*/ */
static void engine_handle_cmd(struct android_app* app, int32_t cmd) { static void engine_handle_cmd(struct android_app* app, int32_t cmd)
{
struct engine* engine = (struct engine*)app->userData; struct engine* engine = (struct engine*)app->userData;
switch (cmd) { switch (cmd) {
case APP_CMD_SAVE_STATE: case APP_CMD_SAVE_STATE:
@ -576,7 +588,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
case APP_CMD_GAINED_FOCUS: case APP_CMD_GAINED_FOCUS:
if (cocos2d::Director::getInstance()->getOpenGLView()) { if (cocos2d::Director::getInstance()->getOpenGLView()) {
cocos2d::Application::getInstance()->applicationWillEnterForeground(); cocos2d::Application::getInstance()->applicationWillEnterForeground();
engine->animating = 1; engine->animating = 1;
} }
break; break;
@ -594,14 +606,14 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
} }
static void onContentRectChanged(ANativeActivity* activity, const ARect* rect) { static void onContentRectChanged(ANativeActivity* activity, const ARect* rect) {
timeRectChanged = std::chrono::steady_clock::now(); timeRectChanged = std::chrono::steady_clock::now();
isContentRectChanged = true; isContentRectChanged = true;
} }
static void process_input(struct android_app* app, struct android_poll_source* source) { static void process_input(struct android_app* app, struct android_poll_source* source)
{
AInputEvent* event = NULL; AInputEvent* event = NULL;
int processed = 0; while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
while (AInputQueue_hasEvents( app->inputQueue ) && AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
LOGV("New input event: type=%d\n", AInputEvent_getType(event)); LOGV("New input event: type=%d\n", AInputEvent_getType(event));
if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
continue; continue;
@ -609,10 +621,6 @@ static void process_input(struct android_app* app, struct android_poll_source* s
int32_t handled = 0; int32_t handled = 0;
if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
AInputQueue_finishEvent(app->inputQueue, event, handled); AInputQueue_finishEvent(app->inputQueue, event, handled);
processed = 1;
}
if (processed == 0) {
LOGE("Failure reading next input event: %s\n", strerror(errno));
} }
} }
/** /**
@ -644,8 +652,8 @@ void android_main(struct android_app* state) {
engine.state = *(struct saved_state*)state->savedState; engine.state = *(struct saved_state*)state->savedState;
} }
// Screen size change support // Screen size change support
state->activity->callbacks->onContentRectChanged = onContentRectChanged; state->activity->callbacks->onContentRectChanged = onContentRectChanged;
// loop waiting for stuff to do. // loop waiting for stuff to do.
@ -735,19 +743,21 @@ void android_main(struct android_app* state) {
LOG_RENDER_DEBUG("android_main : !engine.animating"); LOG_RENDER_DEBUG("android_main : !engine.animating");
} }
// Check if screen size changed // Check if screen size changed
if (isContentRectChanged) { if (isContentRectChanged) {
std::chrono::duration<int, std::milli> duration( std::chrono::duration<int, std::milli> duration(
std::chrono::duration_cast<std::chrono::duration<int, std::milli>>(std::chrono::steady_clock::now() - timeRectChanged)); std::chrono::duration_cast<std::chrono::duration<int, std::milli>>(std::chrono::steady_clock::now() - timeRectChanged));
// Wait about 30 ms to get new width and height. Without waiting we can get old values sometime // Wait about 30 ms to get new width and height. Without waiting we can get old values sometime
if (duration.count() > 30) { if (duration.count() > 30) {
isContentRectChanged = false; isContentRectChanged = false;
int32_t newWidth = ANativeWindow_getWidth(engine.app->window); int32_t newWidth = ANativeWindow_getWidth(engine.app->window);
int32_t newHeight = ANativeWindow_getHeight(engine.app->window); int32_t newHeight = ANativeWindow_getHeight(engine.app->window);
cocos2d::Application::getInstance()->applicationScreenSizeChanged(newWidth, newHeight); cocos2d::Application::getInstance()->applicationScreenSizeChanged(newWidth, newHeight);
} }
} }
} }
} }
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID

View File

@ -24,6 +24,9 @@ THE SOFTWARE.
#ifndef __COCOSNATIVEACTIVITY_H__ #ifndef __COCOSNATIVEACTIVITY_H__
#define __COCOSNATIVEACTIVITY_H__ #define __COCOSNATIVEACTIVITY_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
/** /**
* This is the interface to the Android native activity * This is the interface to the Android native activity
*/ */
@ -32,4 +35,6 @@ void enableAccelerometerJni(void);
void disableAccelerometerJni(void); void disableAccelerometerJni(void);
void setAccelerometerIntervalJni(float interval); void setAccelerometerIntervalJni(float interval);
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#endif // __COCOSNATIVEACTIVITY_H__ #endif // __COCOSNATIVEACTIVITY_H__

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCEGLView.h" #include "CCGLView.h"
#include <unordered_map> #include <unordered_map>
@ -176,8 +176,8 @@ static keyCodeItem g_keyCodeStructArray[] = {
}; };
//begin EGLViewEventHandler //begin GLViewEventHandler
class EGLViewEventHandler class GLViewEventHandler
{ {
public: public:
static bool s_captured; static bool s_captured;
@ -194,18 +194,18 @@ public:
static void onGLFWframebuffersize(GLFWwindow* window, int w, int h); static void onGLFWframebuffersize(GLFWwindow* window, int w, int h);
}; };
bool EGLViewEventHandler::s_captured = false; bool GLViewEventHandler::s_captured = false;
float EGLViewEventHandler::s_mouseX = 0; float GLViewEventHandler::s_mouseX = 0;
float EGLViewEventHandler::s_mouseY = 0; float GLViewEventHandler::s_mouseY = 0;
void EGLViewEventHandler::onGLFWError(int errorID, const char* errorDesc) void GLViewEventHandler::onGLFWError(int errorID, const char* errorDesc)
{ {
CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc); CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc);
} }
void EGLViewEventHandler::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify) void GLViewEventHandler::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
{ {
EGLView* eglView = EGLView::getInstance(); GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return; if(nullptr == eglView) return;
if(GLFW_MOUSE_BUTTON_LEFT == button) if(GLFW_MOUSE_BUTTON_LEFT == button)
{ {
@ -247,9 +247,9 @@ void EGLViewEventHandler::onGLFWMouseCallBack(GLFWwindow* window, int button, in
} }
} }
void EGLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y) void GLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{ {
EGLView* eglView = EGLView::getInstance(); GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return; if(nullptr == eglView) return;
if (eglView->isRetina()) { if (eglView->isRetina()) {
@ -278,9 +278,9 @@ void EGLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x,
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
} }
void EGLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y) void GLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
{ {
EGLView* eglView = EGLView::getInstance(); GLView* eglView = Director::getInstance()->getOpenGLView();
if(nullptr == eglView) return; if(nullptr == eglView) return;
EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL); EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL);
@ -290,7 +290,7 @@ void EGLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
} }
void EGLViewEventHandler::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) void GLViewEventHandler::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{ {
if (GLFW_REPEAT != action) if (GLFW_REPEAT != action)
{ {
@ -300,19 +300,19 @@ void EGLViewEventHandler::onGLFWKeyCallback(GLFWwindow *window, int key, int sca
} }
} }
void EGLViewEventHandler::onGLFWCharCallback(GLFWwindow *window, unsigned int character) void GLViewEventHandler::onGLFWCharCallback(GLFWwindow *window, unsigned int character)
{ {
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1); IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1);
} }
void EGLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y) void GLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
{ {
Director::getInstance()->setViewport(); Director::getInstance()->setViewport();
} }
void EGLViewEventHandler::onGLFWframebuffersize(GLFWwindow* window, int w, int h) void GLViewEventHandler::onGLFWframebuffersize(GLFWwindow* window, int w, int h)
{ {
auto view = EGLView::getInstance(); auto view = Director::getInstance()->getOpenGLView();
float frameSizeW = view->getFrameSize().width; float frameSizeW = view->getFrameSize().width;
float frameSizeH = view->getFrameSize().height; float frameSizeH = view->getFrameSize().height;
@ -334,55 +334,83 @@ void EGLViewEventHandler::onGLFWframebuffersize(GLFWwindow* window, int w, int h
} }
//end EGLViewEventHandler //end GLViewEventHandler
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// implement EGLView // implement GLView
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EGLView* EGLView::s_pEglView = nullptr;
EGLView::EGLView() GLView* GLView::create(const std::string& viewName)
{
auto ret = new GLView;
if(ret && ret->initWithRect(viewName, Rect(0, 0, 960, 640), 1)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
auto ret = new GLView;
if(ret && ret->initWithRect(viewName, rect, frameZoomFactor)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::createWithFullScreen(const std::string& viewName)
{
auto ret = new GLView();
if(ret && ret->initWithFullScreen(viewName)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView::GLView()
: _captured(false) : _captured(false)
, _frameZoomFactor(1.0f) , _frameZoomFactor(1.0f)
, _supportTouch(false) , _supportTouch(false)
, _isRetina(false) , _isRetina(false)
, _mainWindow(nullptr) , _mainWindow(nullptr)
, _primaryMonitor(nullptr)
{ {
CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n");
_viewName = "cocos2dx"; _viewName = "cocos2dx";
s_pEglView = this;
g_keyCodeMap.clear(); g_keyCodeMap.clear();
for (auto& item : g_keyCodeStructArray) for (auto& item : g_keyCodeStructArray)
{ {
g_keyCodeMap[item.glfwKeyCode] = item.keyCode; g_keyCodeMap[item.glfwKeyCode] = item.keyCode;
} }
glfwSetErrorCallback(EGLViewEventHandler::onGLFWError); glfwSetErrorCallback(GLViewEventHandler::onGLFWError);
glfwInit(); glfwInit();
} }
EGLView::~EGLView() GLView::~GLView()
{ {
CCLOGINFO("deallocing EGLView: %p", this); CCLOGINFO("deallocing GLView: %p", this);
glfwTerminate(); glfwTerminate();
s_pEglView = nullptr;
} }
bool EGLView::init(const std::string& viewName, float width, float height, float frameZoomFactor) bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{ {
if(_mainWindow != nullptr)
return true;
setViewName(viewName); setViewName(viewName);
setFrameSize(width, height); setFrameSize(rect.size.width, rect.size.height);
setFrameZoomFactor(frameZoomFactor); setFrameZoomFactor(frameZoomFactor);
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor,
_screenSize.height * _frameZoomFactor, _screenSize.height * _frameZoomFactor,
_viewName.c_str(), _viewName.c_str(),
NULL, // glfwGetPrimaryMonitor() for fullscreen mode _primaryMonitor,
NULL); NULL);
glfwMakeContextCurrent(_mainWindow); glfwMakeContextCurrent(_mainWindow);
@ -395,16 +423,16 @@ bool EGLView::init(const std::string& viewName, float width, float height, float
{ {
_isRetina = true; _isRetina = true;
setFrameZoomFactor(frameZoomFactor * 2); setFrameZoomFactor(frameZoomFactor * 2);
glfwSetWindowSize(_mainWindow, width/2 * _frameZoomFactor, height/2 * _frameZoomFactor); glfwSetWindowSize(_mainWindow, rect.size.width/2 * _frameZoomFactor, rect.size.height/2 * _frameZoomFactor);
} }
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseCallBack); glfwSetMouseButtonCallback(_mainWindow, GLViewEventHandler::onGLFWMouseCallBack);
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseMoveCallBack); glfwSetCursorPosCallback(_mainWindow, GLViewEventHandler::onGLFWMouseMoveCallBack);
glfwSetScrollCallback(_mainWindow, EGLViewEventHandler::onGLFWMouseScrollCallback); glfwSetScrollCallback(_mainWindow, GLViewEventHandler::onGLFWMouseScrollCallback);
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::onGLFWCharCallback); glfwSetCharCallback(_mainWindow, GLViewEventHandler::onGLFWCharCallback);
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::onGLFWKeyCallback); glfwSetKeyCallback(_mainWindow, GLViewEventHandler::onGLFWKeyCallback);
glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::onGLFWWindowPosCallback); glfwSetWindowPosCallback(_mainWindow, GLViewEventHandler::onGLFWWindowPosCallback);
glfwSetFramebufferSizeCallback(_mainWindow, EGLViewEventHandler::onGLFWframebuffersize); glfwSetFramebufferSizeCallback(_mainWindow, GLViewEventHandler::onGLFWframebuffersize);
// check OpenGL version at first // check OpenGL version at first
const GLubyte* glVersion = glGetString(GL_VERSION); const GLubyte* glVersion = glGetString(GL_VERSION);
@ -420,30 +448,40 @@ bool EGLView::init(const std::string& viewName, float width, float height, float
initGlew(); initGlew();
// Enable point size by default on windows. // Enable point size by default.
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
return true; return true;
} }
bool EGLView::isOpenGLReady() bool GLView::initWithFullScreen(const std::string& viewName)
{
_primaryMonitor = glfwGetPrimaryMonitor();
if (nullptr == _primaryMonitor)
return false;
const GLFWvidmode* videoMode = glfwGetVideoMode(_primaryMonitor);
return initWithRect(viewName, Rect(0, 0, videoMode->width, videoMode->height), 1.0f);
}
bool GLView::isOpenGLReady()
{ {
return nullptr != _mainWindow; return nullptr != _mainWindow;
} }
void EGLView::end() void GLView::end()
{ {
if(_mainWindow) if(_mainWindow)
glfwSetWindowShouldClose(_mainWindow,1); glfwSetWindowShouldClose(_mainWindow,1);
} }
void EGLView::swapBuffers() void GLView::swapBuffers()
{ {
if(_mainWindow) if(_mainWindow)
glfwSwapBuffers(_mainWindow); glfwSwapBuffers(_mainWindow);
} }
bool EGLView::windowShouldClose() bool GLView::windowShouldClose()
{ {
if(_mainWindow) if(_mainWindow)
return glfwWindowShouldClose(_mainWindow); return glfwWindowShouldClose(_mainWindow);
@ -451,33 +489,33 @@ bool EGLView::windowShouldClose()
return true; return true;
} }
void EGLView::pollEvents() void GLView::pollEvents()
{ {
glfwPollEvents(); glfwPollEvents();
} }
void EGLView::setIMEKeyboardState(bool /*bOpen*/) void GLView::setIMEKeyboardState(bool /*bOpen*/)
{ {
} }
void EGLView::setFrameZoomFactor(float zoomFactor) void GLView::setFrameZoomFactor(float zoomFactor)
{ {
_frameZoomFactor = zoomFactor; _frameZoomFactor = zoomFactor;
Director::getInstance()->setProjection(Director::getInstance()->getProjection()); Director::getInstance()->setProjection(Director::getInstance()->getProjection());
} }
float EGLView::getFrameZoomFactor() float GLView::getFrameZoomFactor()
{ {
return _frameZoomFactor; return _frameZoomFactor;
} }
void EGLView::setFrameSize(float width, float height) void GLView::setFrameSize(float width, float height)
{ {
EGLViewProtocol::setFrameSize(width, height); GLViewProtocol::setFrameSize(width, height);
} }
void EGLView::setViewPortInPoints(float x , float y , float w , float h) void GLView::setViewPortInPoints(float x , float y , float w , float h)
{ {
glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor), glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor), (GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
@ -485,7 +523,7 @@ void EGLView::setViewPortInPoints(float x , float y , float w , float h)
(GLsizei)(h * _scaleY * _frameZoomFactor)); (GLsizei)(h * _scaleY * _frameZoomFactor));
} }
void EGLView::setScissorInPoints(float x , float y , float w , float h) void GLView::setScissorInPoints(float x , float y , float w , float h)
{ {
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor), glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor), (GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
@ -493,18 +531,6 @@ void EGLView::setScissorInPoints(float x , float y , float w , float h)
(GLsizei)(h * _scaleY * _frameZoomFactor)); (GLsizei)(h * _scaleY * _frameZoomFactor));
} }
EGLView* EGLView::getInstance()
{
CCASSERT(nullptr != s_pEglView, "EGL singleton should not be null");
return s_pEglView;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
static bool glew_dynamic_binding() static bool glew_dynamic_binding()
{ {
@ -570,7 +596,7 @@ static bool glew_dynamic_binding()
#endif #endif
// helper // helper
bool EGLView::initGlew() bool GLView::initGlew()
{ {
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) #if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
GLenum GlewInitResult = glewInit(); GLenum GlewInitResult = glewInit();
@ -604,9 +630,6 @@ bool EGLView::initGlew()
MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error"); MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
return false; return false;
} }
// Enable point size by default on windows.
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif #endif
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) #endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)

View File

@ -26,51 +26,29 @@ THE SOFTWARE.
#ifndef __CC_EGLVIEW_DESKTOP_H__ #ifndef __CC_EGLVIEW_DESKTOP_H__
#define __CC_EGLVIEW_DESKTOP_H__ #define __CC_EGLVIEW_DESKTOP_H__
#include "CCObject.h"
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "platform/CCEGLViewProtocol.h" #include "platform/CCGLViewProtocol.h"
#include "glfw3.h" #include "glfw3.h"
NS_CC_BEGIN NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol class CC_DLL GLView : public Object, public GLViewProtocol
{ {
public: public:
// static function static GLView* create(const std::string& viewName);
/** static GLView* createWithRect(const std::string& viewName, Rect size, float frameZoomFactor = 1.0f);
@brief get the shared main open gl window static GLView* createWithFullScreen(const std::string& viewName);
*/
static EGLView* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
/**
* @js ctor
*/
EGLView();
/**
* @js NA
* @lua NA
*/
virtual ~EGLView();
/* override functions */
virtual bool isOpenGLReady();
virtual void end();
virtual void swapBuffers();
virtual void setFrameSize(float width, float height);
virtual void setIMEKeyboardState(bool bOpen);
/* /*
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. *frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/ */
bool init(const std::string& viewName, float width, float height, float frameZoomFactor = 1.0f);
//void resize(int width, int height); //void resize(int width, int height);
float getFrameZoomFactor(); float getFrameZoomFactor();
//void centerWindow(); //void centerWindow();
virtual void setViewPortInPoints(float x , float y , float w , float h); virtual void setViewPortInPoints(float x , float y , float w , float h);
virtual void setScissorInPoints(float x , float y , float w , float h); virtual void setScissorInPoints(float x , float y , float w , float h);
@ -79,7 +57,20 @@ public:
void pollEvents(); void pollEvents();
GLFWwindow* getWindow() const { return _mainWindow; } GLFWwindow* getWindow() const { return _mainWindow; }
/* override functions */
virtual bool isOpenGLReady() override;
virtual void end() override;
virtual void swapBuffers() override;
virtual void setFrameSize(float width, float height) override;
virtual void setIMEKeyboardState(bool bOpen) override;
protected: protected:
GLView();
virtual ~GLView();
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);
bool initWithFullScreen(const std::string& viewName);
/* /*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/ */
@ -92,10 +83,13 @@ protected:
bool _isRetina; bool _isRetina;
float _frameZoomFactor; float _frameZoomFactor;
static EGLView* s_pEglView;
GLFWwindow* _mainWindow; GLFWwindow* _mainWindow;
friend class EGLViewEventHandler; GLFWmonitor* _primaryMonitor;
friend class GLViewEventHandler;
private:
CC_DISALLOW_COPY_AND_ASSIGN(GLView);
}; };
NS_CC_END // end of namespace cocos2d NS_CC_END // end of namespace cocos2d

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CC_APPLICATION_IOS_H__ #ifndef __CC_APPLICATION_IOS_H__
#define __CC_APPLICATION_IOS_H__ #define __CC_APPLICATION_IOS_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "platform/CCApplicationProtocol.h" #include "platform/CCApplicationProtocol.h"
@ -90,4 +93,6 @@ protected:
NS_CC_END NS_CC_END
#endif // CC_PLATFORM_IOS
#endif // end of __CC_APPLICATION_IOS_H__ #endif // end of __CC_APPLICATION_IOS_H__

View File

@ -25,6 +25,8 @@
#import "CCApplication.h" #import "CCApplication.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "CCGeometry.h" #import "CCGeometry.h"
@ -108,6 +110,9 @@ LanguageType Application::getCurrentLanguage()
else if ([languageCode isEqualToString:@"es"]){ else if ([languageCode isEqualToString:@"es"]){
ret = LanguageType::SPANISH; ret = LanguageType::SPANISH;
} }
else if ([languageCode isEqualToString:@"nl"]){
ret = LanguageType::DUTCH;
}
else if ([languageCode isEqualToString:@"ru"]){ else if ([languageCode isEqualToString:@"ru"]){
ret = LanguageType::RUSSIAN; ret = LanguageType::RUSSIAN;
} }
@ -152,3 +157,5 @@ void Application::applicationScreenSizeChanged(int newWidth, int newHeight) {
} }
NS_CC_END NS_CC_END
#endif // CC_PLATFORM_IOS

View File

@ -23,6 +23,9 @@
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include <stdarg.h> #include <stdarg.h>
@ -54,3 +57,5 @@ void LuaLog(const char * format)
} }
NS_CC_END NS_CC_END
#endif // CC_PLATFORM_IOS

View File

@ -22,6 +22,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "CCDevice.h" #include "CCDevice.h"
#include "ccTypes.h" #include "ccTypes.h"
#include "CCEventDispatcher.h" #include "CCEventDispatcher.h"
@ -174,3 +179,5 @@ void Device::setAccelerometerInterval(float interval)
NS_CC_END NS_CC_END
#endif // CC_PLATFORM_IOS

View File

@ -61,6 +61,9 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
*/ */
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h> #import <OpenGLES/EAGL.h>
#import <OpenGLES/EAGLDrawable.h> #import <OpenGLES/EAGLDrawable.h>
@ -119,9 +122,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
/** creates an initializes an CCEAGLView with a frame, a color buffer format, a depth buffer format, a sharegroup, and multisamping */ /** creates an initializes an CCEAGLView with a frame, a color buffer format, a depth buffer format, a sharegroup, and multisamping */
+ (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples; + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples;
// get the view object
+(id) sharedEGLView;
/** Initializes an CCEAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */ /** Initializes an CCEAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */
- (id) initWithFrame:(CGRect)frame; //These also set the current context - (id) initWithFrame:(CGRect)frame; //These also set the current context
/** Initializes an CCEAGLView with a frame, a color buffer format, and 0-bit depth buffer */ /** Initializes an CCEAGLView with a frame, a color buffer format, and 0-bit depth buffer */
@ -155,3 +155,5 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
-(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis; -(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis;
-(void) doAnimationWhenAnotherEditBeClicked; -(void) doAnimationWhenAnotherEditBeClicked;
@end @end
#endif // CC_PLATFORM_IOS

View File

@ -61,22 +61,23 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
*/ */
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#import "CCEGLView.h" #import "CCGLView.h"
#import "EAGLView.h" #import "CCEAGLView.h"
#import "CCES2Renderer.h" #import "CCES2Renderer.h"
#import "CCDirector.h" #import "CCDirector.h"
#import "CCSet.h" #import "CCSet.h"
#import "CCTouch.h" #import "CCTouch.h"
#import "CCIMEDispatcher.h" #import "CCIMEDispatcher.h"
#import "OpenGL_Internal.h" #import "OpenGL_Internal.h"
#import "CCEGLView.h" #import "CCGLView.h"
//CLASS IMPLEMENTATIONS: //CLASS IMPLEMENTATIONS:
#define IOS_MAX_TOUCHES_COUNT 10 #define IOS_MAX_TOUCHES_COUNT 10
static CCEAGLView *__view = 0;
@interface CCEAGLView (Private) @interface CCEAGLView (Private)
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup; - (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
- (unsigned int) convertPixelFormat:(NSString*) pixelFormat; - (unsigned int) convertPixelFormat:(NSString*) pixelFormat;
@ -115,11 +116,6 @@ static CCEAGLView *__view = 0;
return [[[self alloc]initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained sharegroup:sharegroup multiSampling:multisampling numberOfSamples:samples] autorelease]; return [[[self alloc]initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained sharegroup:sharegroup multiSampling:multisampling numberOfSamples:samples] autorelease];
} }
+ (id) sharedEGLView
{
return __view;
}
- (id) initWithFrame:(CGRect)frame - (id) initWithFrame:(CGRect)frame
{ {
return [self initWithFrame:frame pixelFormat:kEAGLColorFormatRGB565 depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; return [self initWithFrame:frame pixelFormat:kEAGLColorFormatRGB565 depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0];
@ -147,14 +143,12 @@ static CCEAGLView *__view = 0;
} }
__view = self;
originalRect_ = self.frame; originalRect_ = self.frame;
self.keyboardShowNotification = nil; self.keyboardShowNotification = nil;
if ([__view respondsToSelector:@selector(setContentScaleFactor:)]) if ([self respondsToSelector:@selector(setContentScaleFactor:)])
{ {
__view.contentScaleFactor = [[UIScreen mainScreen] scale]; self.contentScaleFactor = [[UIScreen mainScreen] scale];
} }
} }
@ -180,7 +174,6 @@ static CCEAGLView *__view = 0;
} }
} }
__view = self;
return self; return self;
} }
@ -409,11 +402,13 @@ static CCEAGLView *__view = 0;
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (int*)ids, xs, ys);
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesBegin(i, (int*)ids, xs, ys);
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
@ -429,11 +424,13 @@ static CCEAGLView *__view = 0;
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesMove(i, (int*)ids, xs, ys);
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesMove(i, (int*)ids, xs, ys);
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
@ -450,11 +447,13 @@ static CCEAGLView *__view = 0;
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (int*)ids, xs, ys);
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesEnd(i, (int*)ids, xs, ys);
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
@ -471,11 +470,13 @@ static CCEAGLView *__view = 0;
int i = 0; int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
ids[i] = touch; ids[i] = touch;
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
++i; ++i;
} }
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (int*)ids, xs, ys);
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesCancel(i, (int*)ids, xs, ys);
} }
#pragma mark - UIView - Responder #pragma mark - UIView - Responder
@ -795,8 +796,9 @@ static CCEAGLView *__view = 0;
break; break;
} }
float scaleX = cocos2d::EGLView::getInstance()->getScaleX(); auto glview = cocos2d::Director::getInstance()->getOpenGLView();
float scaleY = cocos2d::EGLView::getInstance()->getScaleY(); float scaleX = glview->getScaleX();
float scaleY = glview->getScaleY();
if (self.contentScaleFactor == 2.0f) if (self.contentScaleFactor == 2.0f)
@ -807,7 +809,7 @@ static CCEAGLView *__view = 0;
end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f));
} }
float offestY = cocos2d::EGLView::getInstance()->getViewPortRect().origin.y; float offestY = glview->getViewPortRect().origin.y;
CCLOG("offestY = %f", offestY); CCLOG("offestY = %f", offestY);
if (offestY < 0.0f) if (offestY < 0.0f)
{ {
@ -866,11 +868,12 @@ static CCEAGLView *__view = 0;
[UIView setAnimationDuration:duration]; [UIView setAnimationDuration:duration];
[UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationBeginsFromCurrentState:YES];
//NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::EGLView::getInstance()->getScaleY()); //NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::GLView::getInstance()->getScaleY());
if (dis < 0.0f) dis = 0.0f; if (dis < 0.0f) dis = 0.0f;
dis *= cocos2d::EGLView::getInstance()->getScaleY(); auto glview = cocos2d::Director::getInstance()->getOpenGLView();
dis *= glview->getScaleY();
if (self.contentScaleFactor == 2.0f) if (self.contentScaleFactor == 2.0f)
{ {
@ -912,3 +915,5 @@ static CCEAGLView *__view = 0;
} }
@end @end
#endif // CC_PLATFORM_IOS

View File

@ -1,92 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CC_EGLVIEW_IPHONE_H__
#define __CC_EGLVIEW_IPHONE_H__
#include "platform/CCCommon.h"
#include "platform/CCEGLViewProtocol.h"
NS_CC_BEGIN
class CC_DLL EGLView : public EGLViewProtocol
{
public:
/**
* @js NA
* @lua NA
*/
EGLView();
/**
* @js NA
* @lua NA
*/
~EGLView();
/**
* @js NA
* @lua NA
*/
virtual bool isOpenGLReady();
/**
* @js NA
* @lua NA
*/
virtual bool setContentScaleFactor(float contentScaleFactor);
// keep compatible
/**
* @js NA
* @lua NA
*/
virtual void end();
/**
* @js NA
* @lua NA
*/
virtual void swapBuffers();
/**
* @js NA
* @lua NA
*/
virtual void setIMEKeyboardState(bool bOpen);
/** returns the singleton
* @js NA
*/
static EGLView* getInstance();
/** @deprecated Use getInstance() instead
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
};
NS_CC_END
#endif // end of __CC_EGLVIEW_IPHONE_H__

View File

@ -1,98 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "EAGLView.h"
#include "CCDirectorCaller.h"
#include "CCEGLView.h"
#include "CCSet.h"
#include "CCTouch.h"
NS_CC_BEGIN
EGLView::EGLView()
{
_screenSize.width = _designResolutionSize.width = [[CCEAGLView sharedEGLView] getWidth];
_screenSize.height = _designResolutionSize.height = [[CCEAGLView sharedEGLView] getHeight];
}
EGLView::~EGLView()
{
}
bool EGLView::isOpenGLReady()
{
return [CCEAGLView sharedEGLView] != nullptr;
}
bool EGLView::setContentScaleFactor(float contentScaleFactor)
{
assert(_resolutionPolicy == ResolutionPolicy::UNKNOWN); // cannot enable retina mode
_scaleX = _scaleY = contentScaleFactor;
[[CCEAGLView sharedEGLView] setNeedsLayout];
return true;
}
void EGLView::end()
{
[CCDirectorCaller destroy];
// destroy EAGLView
[[CCEAGLView sharedEGLView] removeFromSuperview];
}
void EGLView::swapBuffers()
{
[[CCEAGLView sharedEGLView] swapBuffers];
}
void EGLView::setIMEKeyboardState(bool bOpen)
{
if (bOpen)
{
[[CCEAGLView sharedEGLView] becomeFirstResponder];
}
else
{
[[CCEAGLView sharedEGLView] resignFirstResponder];
}
}
EGLView* EGLView::getInstance()
{
static EGLView instance;
return &instance;
}
// XXX: deprecated
EGLView* EGLView::sharedOpenGLView()
{
return EGLView::getInstance();
}
NS_CC_END

View File

@ -27,6 +27,10 @@
// Only compile this code on iOS. These files should NOT be included on your Mac project. // Only compile this code on iOS. These files should NOT be included on your Mac project.
// But in case they are included, it won't be compiled. // But in case they are included, it won't be compiled.
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import "CCPlatformMacros.h" #import "CCPlatformMacros.h"
#import "CCESRenderer.h" #import "CCESRenderer.h"
#import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/gl.h>
@ -76,4 +80,4 @@
@end @end
#endif // CC_PLATFORM_IOS

View File

@ -28,8 +28,11 @@
// Only compile this code on iOS. These files should NOT be included on your Mac project. // Only compile this code on iOS. These files should NOT be included on your Mac project.
// But in case they are included, it won't be compiled. // But in case they are included, it won't be compiled.
#import "CCPlatformMacros.h"
#import "CCES2Renderer.h" #import "CCES2Renderer.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import "CCPlatformMacros.h"
#import "OpenGL_Internal.h" #import "OpenGL_Internal.h"
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
@ -251,3 +254,5 @@
@end @end
#endif // CC_PLATFORM_IOS

View File

@ -27,6 +27,10 @@
// Only compile this code on iOS. These files should NOT be included on your Mac project. // Only compile this code on iOS. These files should NOT be included on your Mac project.
// But in case they are included, it won't be compiled. // But in case they are included, it won't be compiled.
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
@ -48,3 +52,4 @@
- (unsigned int) msaaColorBuffer; - (unsigned int) msaaColorBuffer;
@end @end
#endif // CC_PLATFORM_IOS

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __PLATFORM_IOS_CCGL_H__ #ifndef __PLATFORM_IOS_CCGL_H__
#define __PLATFORM_IOS_CCGL_H__ #define __PLATFORM_IOS_CCGL_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#define glClearDepth glClearDepthf #define glClearDepth glClearDepthf
#define glDeleteVertexArrays glDeleteVertexArraysOES #define glDeleteVertexArrays glDeleteVertexArraysOES
#define glGenVertexArrays glGenVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES
@ -39,5 +42,7 @@ THE SOFTWARE.
#include <OpenGLES/ES2/gl.h> #include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h> #include <OpenGLES/ES2/glext.h>
#endif // CC_PLATFORM_IOS
#endif // __PLATFORM_IOS_CCGL_H__ #endif // __PLATFORM_IOS_CCGL_H__

View File

@ -0,0 +1,90 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CC_EGLVIEW_IPHONE_H__
#define __CC_EGLVIEW_IPHONE_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "CCObject.h"
#include "platform/CCCommon.h"
#include "platform/CCGLViewProtocol.h"
NS_CC_BEGIN
/** Class that represent the OpenGL View
*/
class CC_DLL GLView : public Object, public GLViewProtocol
{
public:
/** creates a GLView with a objective-c CCEAGLView instance */
static GLView* createWithEAGLView(void* eaglview);
/** creates a GLView with a title name in fullscreen mode */
static GLView* create(const std::string& viewName);
/** creates a GLView with a title name, a rect and the zoom factor */
static GLView* createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor = 1.0f);
/** creates a GLView with a name in fullscreen mode */
static GLView* createWithFullScreen(const std::string& viewName);
/** sets the content scale factor */
bool setContentScaleFactor(float contentScaleFactor);
/** returns the content scale factor */
float getContentScaleFactor() const;
/** returns whether or not the view is in Retina Display mode */
bool isRetinaDisplay() const { return getContentScaleFactor() == 2.0; }
/** returns the objective-c CCEAGLView instance */
void* getEAGLView() const { return _eaglview; }
// overrides
virtual bool isOpenGLReady() override;
virtual void end() override;
virtual void swapBuffers() override;
virtual void setIMEKeyboardState(bool bOpen) override;
protected:
GLView();
virtual ~GLView();
bool initWithEAGLView(void* eaglview);
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);
bool initWithFullScreen(const std::string& viewName);
// the objective-c CCEAGLView instance
void *_eaglview;
};
NS_CC_END
#endif // CC_PLATFORM_IOS
#endif // end of __CC_EGLVIEW_IPHONE_H__

View File

@ -0,0 +1,201 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <UIKit/UIKit.h>
#include "CCEAGLView.h"
#include "CCDirectorCaller.h"
#include "CCGLView.h"
#include "CCSet.h"
#include "CCTouch.h"
NS_CC_BEGIN
GLView* GLView::createWithEAGLView(void *eaglview)
{
auto ret = new GLView;
if(ret && ret->initWithEAGLView(eaglview)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::create(const std::string& viewName)
{
auto ret = new GLView;
if(ret && ret->initWithFullScreen(viewName)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
auto ret = new GLView;
if(ret && ret->initWithRect(viewName, rect, frameZoomFactor)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView* GLView::createWithFullScreen(const std::string& viewName)
{
auto ret = new GLView();
if(ret && ret->initWithFullScreen(viewName)) {
ret->autorelease();
return ret;
}
return nullptr;
}
GLView::GLView()
{
}
GLView::~GLView()
{
CCEAGLView *glview = (CCEAGLView*) _eaglview;
[glview release];
}
bool GLView::initWithEAGLView(void *eaglview)
{
_eaglview = eaglview;
CCEAGLView *glview = (CCEAGLView*) _eaglview;
_screenSize.width = _designResolutionSize.width = [glview getWidth];
_screenSize.height = _designResolutionSize.height = [glview getHeight];
// _scaleX = _scaleY = [glview contentScaleFactor];
return true;
}
bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r
pixelFormat: kEAGLColorFormatRGB565
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0];
[eaglview setMultipleTouchEnabled:YES];
_screenSize.width = _designResolutionSize.width = [eaglview getWidth];
_screenSize.height = _designResolutionSize.height = [eaglview getHeight];
// _scaleX = _scaleY = [eaglview contentScaleFactor];
_eaglview = eaglview;
return true;
}
bool GLView::initWithFullScreen(const std::string& viewName)
{
CGRect rect = [[UIScreen mainScreen] bounds];
Rect r;
r.origin.x = rect.origin.x;
r.origin.y = rect.origin.y;
r.size.width = rect.size.width;
r.size.height = rect.size.height;
return initWithRect(viewName, r, 1);
}
bool GLView::isOpenGLReady()
{
return _eaglview != nullptr;
}
bool GLView::setContentScaleFactor(float contentScaleFactor)
{
CC_ASSERT(_resolutionPolicy == ResolutionPolicy::UNKNOWN); // cannot enable retina mode
_scaleX = _scaleY = contentScaleFactor;
CCEAGLView *eaglview = (CCEAGLView*) _eaglview;
[eaglview setNeedsLayout];
return true;
}
float GLView::getContentScaleFactor() const
{
CCEAGLView *eaglview = (CCEAGLView*) _eaglview;
float scaleFactor = [eaglview contentScaleFactor];
// CCASSERT(scaleFactor == _scaleX == _scaleY, "Logic error in GLView::getContentScaleFactor");
return scaleFactor;
}
void GLView::end()
{
[CCDirectorCaller destroy];
// destroy EAGLView
CCEAGLView *eaglview = (CCEAGLView*) _eaglview;
[eaglview removeFromSuperview];
[eaglview release];
}
void GLView::swapBuffers()
{
CCEAGLView *eaglview = (CCEAGLView*) _eaglview;
[eaglview swapBuffers];
}
void GLView::setIMEKeyboardState(bool open)
{
CCEAGLView *eaglview = (CCEAGLView*) _eaglview;
if (open)
{
[eaglview becomeFirstResponder];
}
else
{
[eaglview resignFirstResponder];
}
}
NS_CC_END
#endif // CC_PLATFOR_IOS

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "CCImageCommon_cpp.h" #include "CCImageCommon_cpp.h"
#import "CCImage.h" #import "CCImage.h"
@ -468,3 +472,5 @@ bool Image::saveToFile(const std::string& filename, bool isToRGB)
NS_CC_END NS_CC_END
#endif // CC_PLATFORM_IOS

View File

@ -25,6 +25,9 @@ THE SOFTWARE.
#ifndef __CCPLATFORMDEFINE_H__ #ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include <assert.h> #include <assert.h>
#define CC_DLL #define CC_DLL
@ -44,5 +47,6 @@ THE SOFTWARE.
#endif #endif
#endif // CC_PLATFORM_IOS
#endif /* __CCPLATFORMDEFINE_H__*/ #endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CC_STD_C_H__ #ifndef __CC_STD_C_H__
#define __CC_STD_C_H__ #define __CC_STD_C_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#include <float.h> #include <float.h>
#include <math.h> #include <math.h>
@ -45,4 +48,5 @@ THE SOFTWARE.
#define MAX(x,y) (((x) < (y)) ? (y) : (x)) #define MAX(x,y) (((x) < (y)) ? (y) : (x))
#endif // MAX #endif // MAX
#endif // CC_PLATFORM_IOS
#endif // __CC_STD_C_H__ #endif // __CC_STD_C_H__

View File

@ -61,6 +61,9 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
*/ */
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
/* Generic error reporting */ /* Generic error reporting */
#define REPORT_ERROR(__FORMAT__, ...) printf("%s: %s\n", __FUNCTION__, [[NSString stringWithFormat:__FORMAT__, __VA_ARGS__] UTF8String]) #define REPORT_ERROR(__FORMAT__, ...) printf("%s: %s\n", __FUNCTION__, [[NSString stringWithFormat:__FORMAT__, __VA_ARGS__] UTF8String])
@ -79,3 +82,5 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
#endif #endif
#define TEST_DELEGATE_METHOD_BIT(__BIT__) (self->__DELEGATE_METHODS_IVAR__ & (1 << __BIT__)) #define TEST_DELEGATE_METHOD_BIT(__BIT__) (self->__DELEGATE_METHODS_IVAR__ & (1 << __BIT__))
#define SET_DELEGATE_METHOD_BIT(__BIT__, __NAME__) { if([self->__DELEGATE_IVAR__ respondsToSelector:@selector(__NAME__)]) self->__DELEGATE_METHODS_IVAR__ |= (1 << __BIT__); else self->__DELEGATE_METHODS_IVAR__ &= ~(1 << __BIT__); } #define SET_DELEGATE_METHOD_BIT(__BIT__, __NAME__) { if([self->__DELEGATE_IVAR__ respondsToSelector:@selector(__NAME__)]) self->__DELEGATE_METHODS_IVAR__ |= (1 << __BIT__); else self->__DELEGATE_METHODS_IVAR__ &= ~(1 << __BIT__); }
#endif // CC_PLATFORM_IOS

View File

@ -23,6 +23,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <TargetConditionals.h> #import <TargetConditionals.h>
// when compiling to ARM (iPhone device), hide everything and use system defaults // when compiling to ARM (iPhone device), hide everything and use system defaults
@ -73,4 +77,6 @@ THE SOFTWARE.
@end @end
#endif #endif // !TARGET_CPU_ARM
#endif // CC_PLATFORM_IOS

View File

@ -26,6 +26,8 @@ THE SOFTWARE.
#import "AccelerometerSimulation.h" #import "AccelerometerSimulation.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
// when compiling to ARM (iPhone device), hide everything and use system defaults // when compiling to ARM (iPhone device), hide everything and use system defaults
// if you wish to use simulation mode even on the device, remove the #if/#endif // if you wish to use simulation mode even on the device, remove the #if/#endif
#if !TARGET_CPU_ARM #if !TARGET_CPU_ARM
@ -263,4 +265,6 @@ static CCAccelerometerSimulation *sharedAccelerometer = NULL;
} }
@end @end
#endif #endif // !TARGET_CPU_ARM
#endif // CC_PLATFORM_IOS

View File

@ -23,13 +23,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "CCApplication.h" #include "CCApplication.h"
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <string> #include <string>
#include "CCDirector.h" #include "CCDirector.h"
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "CCEGLView.h" #include "CCGLView.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -38,61 +41,62 @@ NS_CC_BEGIN
Application * Application::sm_pSharedApplication = 0; Application * Application::sm_pSharedApplication = 0;
static long getCurrentMillSecond() { static long getCurrentMillSecond() {
long lLastTime; long lLastTime;
struct timeval stCurrentTime; struct timeval stCurrentTime;
gettimeofday(&stCurrentTime,NULL); gettimeofday(&stCurrentTime,NULL);
lLastTime = stCurrentTime.tv_sec*1000+stCurrentTime.tv_usec*0.001; //millseconds lLastTime = stCurrentTime.tv_sec*1000+stCurrentTime.tv_usec*0.001; //millseconds
return lLastTime; return lLastTime;
} }
Application::Application() Application::Application()
{ {
CC_ASSERT(! sm_pSharedApplication); CC_ASSERT(! sm_pSharedApplication);
sm_pSharedApplication = this; sm_pSharedApplication = this;
} }
Application::~Application() Application::~Application()
{ {
CC_ASSERT(this == sm_pSharedApplication); CC_ASSERT(this == sm_pSharedApplication);
sm_pSharedApplication = NULL; sm_pSharedApplication = NULL;
_animationInterval = 1.0f/60.0f*1000.0f; _animationInterval = 1.0f/60.0f*1000.0f;
} }
int Application::run() int Application::run()
{ {
// Initialize instance and cocos2d. // Initialize instance and cocos2d.
if (! applicationDidFinishLaunching()) if (! applicationDidFinishLaunching())
{
return 0;
}
EGLView* pMainWnd = EGLView::getInstance();
while (!pMainWnd->windowShouldClose())
{ {
long iLastTime = getCurrentMillSecond(); return 0;
Director::getInstance()->mainLoop(); }
pMainWnd->pollEvents();
long iCurTime = getCurrentMillSecond(); auto director = Director::getInstance();
if (iCurTime-iLastTime<_animationInterval){ auto glview = director->getOpenGLView();
usleep((_animationInterval - iCurTime+iLastTime)*1000);
} while (!glview->windowShouldClose())
{
long iLastTime = getCurrentMillSecond();
director->mainLoop();
glview->pollEvents();
long iCurTime = getCurrentMillSecond();
if (iCurTime-iLastTime<_animationInterval){
usleep((_animationInterval - iCurTime+iLastTime)*1000);
}
} }
/* Only work on Desktop /* Only work on Desktop
* Director::mainLoop is really one frame logic * Director::mainLoop is really one frame logic
* when we want to close the window, we should call Director::end(); * when we want to close the window, we should call Director::end();
* then call Director::mainLoop to do release of internal resources * then call Director::mainLoop to do release of internal resources
*/ */
Director::getInstance()->end(); director->end();
Director::getInstance()->mainLoop(); director->mainLoop();
return -1; return -1;
} }
void Application::setAnimationInterval(double interval) void Application::setAnimationInterval(double interval)
{ {
//TODO do something else //TODO do something else
_animationInterval = interval*1000.0f; _animationInterval = interval*1000.0f;
} }
void Application::setResourceRootPath(const std::string& rootResDir) void Application::setResourceRootPath(const std::string& rootResDir)
@ -123,8 +127,8 @@ Application::Platform Application::getTargetPlatform()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
Application* Application::getInstance() Application* Application::getInstance()
{ {
CC_ASSERT(sm_pSharedApplication); CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication; return sm_pSharedApplication;
} }
// @deprecated Use getInstance() instead // @deprecated Use getInstance() instead
@ -171,6 +175,10 @@ LanguageType Application::getCurrentLanguage()
{ {
ret = LanguageType::SPANISH; ret = LanguageType::SPANISH;
} }
else if (0 == strcmp("nl", pLanguageName))
{
ret = LanguageType::DUTCH;
}
else if (0 == strcmp("ru", pLanguageName)) else if (0 == strcmp("ru", pLanguageName))
{ {
ret = LanguageType::RUSSIAN; ret = LanguageType::RUSSIAN;
@ -188,23 +196,26 @@ LanguageType Application::getCurrentLanguage()
ret = LanguageType::HUNGARIAN; ret = LanguageType::HUNGARIAN;
} }
else if (0 == strcmp("pt", pLanguageName)) else if (0 == strcmp("pt", pLanguageName))
{ {
ret = LanguageType::PORTUGUESE; ret = LanguageType::PORTUGUESE;
} }
else if (0 == strcmp("ar", pLanguageName)) else if (0 == strcmp("ar", pLanguageName))
{ {
ret = LanguageType::ARABIC; ret = LanguageType::ARABIC;
} }
else if (0 == strcmp("nb", pLanguageName)) else if (0 == strcmp("nb", pLanguageName))
{ {
ret = LanguageType::NORWEGIAN; ret = LanguageType::NORWEGIAN;
} }
else if (0 == strcmp("pl", pLanguageName)) else if (0 == strcmp("pl", pLanguageName))
{ {
ret = LanguageType::POLISH; ret = LanguageType::POLISH;
} }
return ret; return ret;
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef CCAPLICATION_H_ #ifndef CCAPLICATION_H_
#define CCAPLICATION_H_ #define CCAPLICATION_H_
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "platform/CCApplicationProtocol.h" #include "platform/CCApplicationProtocol.h"
#include <string> #include <string>
@ -94,4 +97,6 @@ protected:
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#endif /* CCAPLICATION_H_ */ #endif /* CCAPLICATION_H_ */

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "CCStdC.h" #include "CCStdC.h"
#include "CCConsole.h" #include "CCConsole.h"
@ -39,3 +43,5 @@ void LuaLog(const char * format)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "platform/CCDevice.h" #include "platform/CCDevice.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <stdio.h> #include <stdio.h>
@ -64,3 +68,5 @@ void Device::setAccelerometerInterval(float interval)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "CCFileUtilsLinux.h" #include "CCFileUtilsLinux.h"
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "ccMacros.h" #include "ccMacros.h"
@ -114,3 +118,5 @@ bool FileUtilsLinux::isFileExist(const std::string& strFilePath) const
} }
NS_CC_END NS_CC_END
#endif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -25,6 +25,9 @@ THE SOFTWARE.
#ifndef __CC_FILEUTILS_LINUX_H__ #ifndef __CC_FILEUTILS_LINUX_H__
#define __CC_FILEUTILS_LINUX_H__ #define __CC_FILEUTILS_LINUX_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#include "ccTypes.h" #include "ccTypes.h"
@ -56,5 +59,6 @@ public:
NS_CC_END NS_CC_END
#endif // __CC_FILEUTILS_LINUX_H__ #endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#endif // __CC_FILEUTILS_LINUX_H__

View File

@ -25,8 +25,13 @@ THE SOFTWARE.
#ifndef __CCGL_H__ #ifndef __CCGL_H__
#define __CCGL_H__ #define __CCGL_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "GL/glew.h" #include "GL/glew.h"
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#endif // __CCGL_H__ #endif // __CCGL_H__

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>
@ -450,23 +454,21 @@ static BitmapDC& sharedBitmapDC()
} }
bool Image::initWithString( bool Image::initWithString(
const char * pText, const char * text,
int nWidth/* = 0*/, int width/* = 0*/,
int nHeight/* = 0*/, int height/* = 0*/,
TextAlign eAlignMask/* = kAlignCenter*/, TextAlign alignMask/* = kAlignCenter*/,
const char * pFontName/* = nil*/, const char * fontName/* = nil*/,
int nSize/* = 0*/) int size/* = 0*/)
{ {
bool bRet = false; bool ret = false;
do do
{ {
CC_BREAK_IF(! pText); CC_BREAK_IF(!text || 0 == strlen(text));
BitmapDC &dc = sharedBitmapDC(); BitmapDC &dc = sharedBitmapDC();
//const char* pFullFontName = FileUtils::getInstance()->fullPathFromRelativePath(pFontName); CC_BREAK_IF(! dc.getBitmap(text, width, height, alignMask, fontName, size));
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));
// assign the dc._data to _data in order to save time // assign the dc._data to _data in order to save time
_data = dc._data; _data = dc._data;
@ -478,13 +480,15 @@ bool Image::initWithString(
_preMulti = true; _preMulti = true;
_dataLen = _width * _height * 4; _dataLen = _width * _height * 4;
bRet = true; ret = true;
dc.reset(); dc.reset();
}while (0); }while (0);
//do nothing //do nothing
return bRet; return ret;
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -22,9 +22,13 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __CCPLATFORMDEFINE_H__ #ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include <string.h> #include <string.h>
#if defined(_USRDLL) #if defined(_USRDLL)
@ -47,5 +51,6 @@ THE SOFTWARE.
#endif #endif
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#endif /* __CCPLATFORMDEFINE_H__*/ #endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -23,6 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "CCStdC.h" #include "CCStdC.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
@ -65,5 +68,6 @@ int CC_DLL gettimeofday(struct timeval * val, struct timezone *)
return 0; return 0;
} }
#endif // CC_PLATFORM_WIN32 #endif // CC_PLATFORM_WIN32
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CC_STD_C_H__ #ifndef __CC_STD_C_H__
#define __CC_STD_C_H__ #define __CC_STD_C_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#include <float.h> #include <float.h>
@ -52,4 +55,6 @@ THE SOFTWARE.
#define cosf cos #define cosf cos
#define sinf sin #define sinf sin
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#endif // __CC_STD_C_H__ #endif // __CC_STD_C_H__

View File

@ -26,6 +26,9 @@ THE SOFTWARE.
#ifndef __CC_APPLICATION_MAC_H__ #ifndef __CC_APPLICATION_MAC_H__
#define __CC_APPLICATION_MAC_H__ #define __CC_APPLICATION_MAC_H__
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "platform/CCApplicationProtocol.h" #include "platform/CCApplicationProtocol.h"
#include <string> #include <string>
@ -52,7 +55,7 @@ public:
virtual void setAnimationInterval(double interval); virtual void setAnimationInterval(double interval);
/** /**
@brief Get status bar rectangle in EGLView window. @brief Get status bar rectangle in GLView window.
*/ */
/** /**
@ -107,4 +110,6 @@ protected:
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#endif // end of __CC_APPLICATION_MAC_H__; #endif // end of __CC_APPLICATION_MAC_H__;

View File

@ -23,6 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#import "CCApplication.h" #import "CCApplication.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <algorithm> #include <algorithm>
@ -30,7 +33,7 @@ THE SOFTWARE.
#include "CCGeometry.h" #include "CCGeometry.h"
#include "CCDirector.h" #include "CCDirector.h"
#import "CCDirectorCaller.h" #import "CCDirectorCaller.h"
#include "CCEGLView.h" #include "CCGLView.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -54,12 +57,12 @@ int Application::run()
{ {
return 0; return 0;
} }
EGLView* pMainWnd = EGLView::getInstance(); GLView* glview = Director::getInstance()->getOpenGLView();
while (!pMainWnd->windowShouldClose()) while (!glview->windowShouldClose())
{ {
Director::getInstance()->mainLoop(); Director::getInstance()->mainLoop();
pMainWnd->pollEvents(); glview->pollEvents();
} }
/* Only work on Desktop /* Only work on Desktop
@ -130,6 +133,9 @@ LanguageType Application::getCurrentLanguage()
else if ([languageCode isEqualToString:@"es"]){ else if ([languageCode isEqualToString:@"es"]){
ret = LanguageType::SPANISH; ret = LanguageType::SPANISH;
} }
else if ([languageCode isEqualToString:@"nl"]){
ret = LanguageType::DUTCH;
}
else if ([languageCode isEqualToString:@"ru"]){ else if ([languageCode isEqualToString:@"ru"]){
ret = LanguageType::RUSSIAN; ret = LanguageType::RUSSIAN;
} }
@ -189,3 +195,5 @@ const std::string& Application::getStartupScriptFilename(void)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC

View File

@ -22,8 +22,15 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "CCEGLView.h"
#include "CCDirector.h"
#include "CCGLView.h"
#define GLFW_EXPOSE_NATIVE_NSGL #define GLFW_EXPOSE_NATIVE_NSGL
#define GLFW_EXPOSE_NATIVE_COCOA #define GLFW_EXPOSE_NATIVE_COCOA
#include "glfw3native.h" #include "glfw3native.h"
@ -51,7 +58,8 @@ void MessageBox(const char * msg, const char * title)
[alert setInformativeText:tmpTitle]; [alert setInformativeText:tmpTitle];
[alert setAlertStyle:NSWarningAlertStyle]; [alert setAlertStyle:NSWarningAlertStyle];
id window = glfwGetCocoaWindow(EGLView::getInstance()->getWindow()); GLView* glview = Director::getInstance()->getOpenGLView();
id window = glfwGetCocoaWindow(glview->getWindow());
[alert beginSheetModalForWindow:window [alert beginSheetModalForWindow:window
modalDelegate:[window delegate] modalDelegate:[window delegate]
didEndSelector:nil didEndSelector:nil
@ -59,3 +67,6 @@ void MessageBox(const char * msg, const char * title)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#include "platform/CCDevice.h" #include "platform/CCDevice.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -43,3 +47,5 @@ void Device::setAccelerometerInterval(float interval)
} }
NS_CC_END NS_CC_END
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC

View File

@ -22,6 +22,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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <QuartzCore/CVDisplayLink.h> #import <QuartzCore/CVDisplayLink.h>
@ -38,3 +42,5 @@ THE SOFTWARE.
+(id) sharedDirectorCaller; +(id) sharedDirectorCaller;
@end @end
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC

Some files were not shown because too many files have changed in this diff Show More