mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2920_voice_recognition_input_crash_on_ios7
This commit is contained in:
commit
20ee1d2666
|
@ -4,12 +4,12 @@
|
|||
[submodule "cocos/scripting/auto-generated"]
|
||||
path = cocos/scripting/auto-generated
|
||||
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"]
|
||||
path = tools/cocos2d-console
|
||||
url = git://github.com/cocos2d/cocos2d-console.git
|
||||
[submodule "plugin"]
|
||||
path = plugin
|
||||
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
|
||||
|
|
1
AUTHORS
1
AUTHORS
|
@ -95,6 +95,7 @@ Developers:
|
|||
Added Mingw-crt Support without breaking VS SDK
|
||||
CMake support for windows.
|
||||
Added support for x64 target of windows.
|
||||
Added Dutch Language support.
|
||||
|
||||
mchinen
|
||||
fix emulator issue for OpenGL ES 2.0 on Android
|
||||
|
|
15
CHANGELOG
15
CHANGELOG
|
@ -1,3 +1,10 @@
|
|||
cocos2d-x-3.0rc0 Feb.?? 2014
|
||||
[All]
|
||||
[NEW] Adds Dutch Language support.
|
||||
|
||||
[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.
|
||||
|
||||
cocos2d-x-3.0beta2 Jan.24 2014
|
||||
[All]
|
||||
[NEW] Full screen support for desktop platforms.
|
||||
|
@ -11,8 +18,7 @@ cocos2d-x-3.0beta2 Jan.24 2014
|
|||
[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%
|
||||
|
||||
[FIX] Uses EventDispatcher to access event in LUA testcase.
|
||||
[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] 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.
|
||||
|
@ -53,6 +59,7 @@ cocos2d-x-3.0beta2 Jan.24 2014
|
|||
[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
|
||||
|
@ -819,7 +826,7 @@ cocos2d-2.0-x-2.0.2 @Aug.30 2012
|
|||
Refactor #1399: adjust directory structure
|
||||
Refactor #1402: improve static creator function names to avoid confusion
|
||||
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 #1442: use CREATE_FUNC to replace LAYER_CREATE_FUNC and SCENE_CREATE_FUNC
|
||||
[iOS]
|
||||
|
@ -853,7 +860,7 @@ cocos2d-2.0-rc2-x-2.0.1 @Jun.28 2012
|
|||
Bug #1293: fix a bug that CCDirector::getFrames() returns wrong value
|
||||
Bug #1296: fix a logical error in CCTMXTiledMap::tilesetForLayer()
|
||||
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 #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
|
||||
|
|
|
@ -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_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_HelloLua "Only build HelloLua sample" OFF)
|
||||
option(BUILD_TestLua "Only build TestLua sample" OFF)
|
||||
|
||||
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_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_HelloLua "Only build HelloLua sample" ON)
|
||||
option(BUILD_TestLua "Only build TestLua sample" ON)
|
||||
|
||||
endif()#temp
|
||||
|
@ -284,20 +279,13 @@ add_subdirectory(external/lua/tolua)
|
|||
add_subdirectory(cocos/scripting)
|
||||
endif(BUILD_LIBS_LUA)
|
||||
|
||||
# build samples
|
||||
if(BUILD_HelloCpp)
|
||||
add_subdirectory(samples/Cpp/HelloCpp)
|
||||
endif(BUILD_HelloCpp)
|
||||
# build tests
|
||||
|
||||
if(BUILD_TestCpp)
|
||||
add_subdirectory(samples/Cpp/TestCpp)
|
||||
add_subdirectory(tests/test-cpp)
|
||||
endif(BUILD_TestCpp)
|
||||
|
||||
if(BUILD_HelloLua)
|
||||
add_subdirectory(samples/Lua/HelloLua)
|
||||
endif(BUILD_HelloLua)
|
||||
|
||||
if(BUILD_TestLua)
|
||||
add_subdirectory(samples/Lua/TestLua)
|
||||
add_subdirectory(tests/test-lua)
|
||||
endif(BUILD_TestLua)
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/python
|
||||
# android-build.py
|
||||
# Build android samples
|
||||
# Build android
|
||||
|
||||
import sys
|
||||
import os, os.path
|
||||
import shutil
|
||||
from optparse import OptionParser
|
||||
|
||||
CPP_SAMPLES = ['hellocpp', 'testcpp', 'simplegame', 'assetsmanager']
|
||||
LUA_SAMPLES = ['hellolua', 'testlua']
|
||||
JSB_SAMPLES = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme']
|
||||
CPP_SAMPLES = ['testcpp']
|
||||
LUA_SAMPLES = ['testlua']
|
||||
JSB_SAMPLES = ['testjavascript']
|
||||
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES
|
||||
|
||||
def get_num_of_cpu():
|
||||
|
@ -74,9 +74,9 @@ def select_toolchain_version():
|
|||
|
||||
def caculate_built_samples(args):
|
||||
''' Compute the sampels to be built
|
||||
'cpp' for short of all cpp samples
|
||||
'lua' for short of all lua smpleas
|
||||
'jsb' for short of all javascript samples
|
||||
'cpp' for short of all cpp tests
|
||||
'lua' for short of all lua tests
|
||||
'jsb' for short of all javascript tests
|
||||
'''
|
||||
|
||||
if 'all' in args:
|
||||
|
@ -159,47 +159,23 @@ def copy_resources(target, app_android_root):
|
|||
|
||||
# jsb samples should copy javascript files and resources(shared with cocos2d-html5)
|
||||
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)
|
||||
|
||||
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":
|
||||
resources_dir = os.path.join(app_android_root, "../../Shared/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)
|
||||
resources_dir = os.path.join(app_android_root, "../tests/")
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
# lua samples should copy lua script
|
||||
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)
|
||||
|
||||
# TestLua shared resources with TestCpp
|
||||
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)
|
||||
|
||||
def build_samples(target,ndk_build_param,android_platform,build_mode):
|
||||
|
@ -227,28 +203,12 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
|
|||
|
||||
app_android_root = ''
|
||||
for target in build_targets:
|
||||
if target == 'hellocpp':
|
||||
app_android_root = os.path.join(cocos_root, 'samples/Cpp/HelloCpp/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')
|
||||
if target == 'testcpp':
|
||||
app_android_root = os.path.join(cocos_root, 'tests/test-cpp/proj.android')
|
||||
elif target == 'testlua':
|
||||
app_android_root = os.path.join(cocos_root, 'samples/Lua/TestLua/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')
|
||||
app_android_root = os.path.join(cocos_root, 'tests/test-lua/proj.android')
|
||||
elif target == 'testjavascript':
|
||||
app_android_root = os.path.join(cocos_root, 'samples/Javascript/TestJavascript/proj.android')
|
||||
elif target == 'watermelonwithme':
|
||||
app_android_root = os.path.join(cocos_root, 'samples/Javascript/WatermelonWithMe/proj.android')
|
||||
app_android_root = os.path.join(cocos_root, 'tests/test-javascript/proj.android')
|
||||
else:
|
||||
print 'unknown target: %s' % target
|
||||
continue
|
||||
|
@ -261,30 +221,30 @@ if __name__ == '__main__':
|
|||
|
||||
#parse the params
|
||||
usage = """
|
||||
This script is mainy used for building samples built-in with cocos2d-x.
|
||||
This script is mainy used for building tests built-in with cocos2d-x.
|
||||
|
||||
Usage: %prog [options] target
|
||||
|
||||
Valid targets are: [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon|crystalcraze|moonwarriors|testjavascript|watermelonwithme]. You can combine them arbitrarily with a whitespace among two valid targets.
|
||||
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 samples, or all the c++ samples, or all the lua samples, or all the jsb samples respectevely.
|
||||
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 = ['hellocpp', 'testcpp', 'simplegame', 'assetsmanager']
|
||||
lua = ['hellolua', 'testlua']
|
||||
jsb = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme']
|
||||
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 hellocpp,hellolua or testjavascript.
|
||||
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 simplegame assetsmanager
|
||||
python android-build.py -p 10 testcpp testlua
|
||||
|
||||
//2. to build hellolua and all the jsb samples
|
||||
python android-build.py -p 19 hellolua jsb
|
||||
//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 samples. But it is optional. You can generate apk with eclipse.
|
||||
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)
|
||||
|
|
|
@ -5,15 +5,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos\audio\
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
|
||||
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}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}"
|
||||
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
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}"
|
||||
EndProject
|
||||
|
@ -25,29 +23,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\cocos\netw
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}"
|
||||
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}"
|
||||
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
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}"
|
||||
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}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "..\samples\Lua\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}"
|
||||
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}"
|
||||
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}") = "libJSBindingForBuilder", "..\cocos\scripting\javascript\bindings\cocosbuilder\libJSBindingForBuilder.vcxproj", "{F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}"
|
||||
EndProject
|
||||
|
|
|
@ -1 +1 @@
|
|||
3c7f70ab861d6d3348d4f598cf492b29b306d9d9
|
||||
caae58ff83f2655d5ea4c19e00a2be17259f8559
|
|
@ -1 +0,0 @@
|
|||
c958533394964fe0c38bd60c272a0b48ec38d9d6
|
|
@ -0,0 +1 @@
|
|||
88d35147fd70ffbc353388aa9424bd2f0645ac95
|
|
@ -111,7 +111,7 @@ cocos2d.cpp \
|
|||
TGAlib.cpp \
|
||||
TransformUtils.cpp \
|
||||
ZipUtils.cpp \
|
||||
platform/CCEGLViewProtocol.cpp \
|
||||
platform/CCGLViewProtocol.cpp \
|
||||
platform/CCFileUtils.cpp \
|
||||
platform/CCSAXParser.cpp \
|
||||
platform/CCThread.cpp \
|
||||
|
|
|
@ -764,7 +764,7 @@ CC_DEPRECATED_ATTRIBUTE typedef TMXTiledMap CCTMXTiledMap;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef TileMapAtlas CCTileMapAtlas;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer;
|
||||
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 AffineTransform CCAffineTransform;
|
||||
|
|
|
@ -55,7 +55,7 @@ THE SOFTWARE.
|
|||
#include "kazmath/GL/matrix.h"
|
||||
#include "CCProfiling.h"
|
||||
#include "platform/CCImage.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
#include "CCConfiguration.h"
|
||||
#include "CCEventDispatcher.h"
|
||||
#include "CCEventCustom.h"
|
||||
|
@ -365,7 +365,7 @@ float Director::getDeltaTime() const
|
|||
{
|
||||
return _deltaTime;
|
||||
}
|
||||
void Director::setOpenGLView(EGLView *openGLView)
|
||||
void Director::setOpenGLView(GLView *openGLView)
|
||||
{
|
||||
CCASSERT(openGLView, "opengl view should not be null");
|
||||
|
||||
|
@ -376,9 +376,10 @@ void Director::setOpenGLView(EGLView *openGLView)
|
|||
conf->gatherGPUInfo();
|
||||
CCLOG("%s\n",conf->getInfo().c_str());
|
||||
|
||||
// EAGLView is not a Object
|
||||
delete _openGLView; // [openGLView_ release]
|
||||
if(_openGLView)
|
||||
_openGLView->release();
|
||||
_openGLView = openGLView;
|
||||
_openGLView->retain();
|
||||
|
||||
// set size
|
||||
_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,
|
||||
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->retain();
|
||||
|
|
|
@ -49,7 +49,7 @@ NS_CC_BEGIN
|
|||
/* Forward declarations. */
|
||||
class LabelAtlas;
|
||||
class Scene;
|
||||
class EGLView;
|
||||
class GLView;
|
||||
class DirectorDelegate;
|
||||
class Node;
|
||||
class Scheduler;
|
||||
|
@ -143,12 +143,12 @@ public:
|
|||
/** seconds per frame */
|
||||
inline float getSecondsPerFrame() { return _secondsPerFrame; }
|
||||
|
||||
/** Get the EGLView, where everything is rendered
|
||||
/** Get the GLView, where everything is rendered
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
inline EGLView* getOpenGLView() { return _openGLView; }
|
||||
void setOpenGLView(EGLView *openGLView);
|
||||
inline GLView* getOpenGLView() { return _openGLView; }
|
||||
void setOpenGLView(GLView *openGLView);
|
||||
|
||||
TextureCache* getTextureCache() const;
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
|||
|
||||
/** returns visible size of the OpenGL view in points.
|
||||
* the value is equal to getWinSize if don't invoke
|
||||
* EGLView::setDesignResolutionSize()
|
||||
* GLView::setDesignResolutionSize()
|
||||
*/
|
||||
Size getVisibleSize() const;
|
||||
|
||||
|
@ -422,8 +422,8 @@ protected:
|
|||
/* delta time since last tick to main loop */
|
||||
float _deltaTime;
|
||||
|
||||
/* The EGLView, where everything is rendered */
|
||||
EGLView *_openGLView;
|
||||
/* The GLView, where everything is rendered */
|
||||
GLView *_openGLView;
|
||||
|
||||
//texture cache belongs to this director
|
||||
TextureCache *_textureCache;
|
||||
|
@ -492,8 +492,8 @@ protected:
|
|||
/* Console for the director */
|
||||
Console *_console;
|
||||
|
||||
// EGLViewProtocol will recreate stats labels to fit visible rect
|
||||
friend class EGLViewProtocol;
|
||||
// GLViewProtocol will recreate stats labels to fit visible rect
|
||||
friend class GLViewProtocol;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -815,7 +815,7 @@ void EventDispatcher::dispatchTouchEvent(EventTouch* event)
|
|||
if (event->isStopped())
|
||||
{
|
||||
updateListeners(event);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
EventCode _eventCode;
|
||||
std::vector<Touch*> _touches;
|
||||
|
||||
friend class EGLViewProtocol;
|
||||
friend class GLViewProtocol;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
|
|||
|
||||
break;
|
||||
}
|
||||
_usedGlyphs = glyphs;
|
||||
}
|
||||
|
||||
const char * Font::getCurrentGlyphCollection() const
|
||||
|
|
|
@ -26,7 +26,7 @@ THE SOFTWARE.
|
|||
#include "CCTextFieldTTF.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -126,7 +126,7 @@ bool TextFieldTTF::attachWithIME()
|
|||
if (ret)
|
||||
{
|
||||
// open keyboard
|
||||
EGLView * pGlView = Director::getInstance()->getOpenGLView();
|
||||
GLView * pGlView = Director::getInstance()->getOpenGLView();
|
||||
if (pGlView)
|
||||
{
|
||||
pGlView->setIMEKeyboardState(true);
|
||||
|
@ -141,7 +141,7 @@ bool TextFieldTTF::detachWithIME()
|
|||
if (ret)
|
||||
{
|
||||
// close keyboard
|
||||
EGLView * glView = Director::getInstance()->getOpenGLView();
|
||||
GLView * glView = Director::getInstance()->getOpenGLView();
|
||||
if (glView)
|
||||
{
|
||||
glView->setIMEKeyboardState(false);
|
||||
|
|
|
@ -7,7 +7,7 @@ set(PLATFORM_SRC
|
|||
platform/win32/CCFileUtilsWin32.cpp
|
||||
platform/win32/CCCommon.cpp
|
||||
platform/win32/CCApplication.cpp
|
||||
platform/win32/CCEGLView.cpp
|
||||
platform/win32/CCGLView.cpp
|
||||
platform/win32/CCImage.cpp
|
||||
platform/win32/CCDevice.cpp
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ set(PLATFORM_SRC
|
|||
platform/linux/CCFileUtilsLinux.cpp
|
||||
platform/linux/CCCommon.cpp
|
||||
platform/linux/CCApplication.cpp
|
||||
platform/desktop/CCEGLView.cpp
|
||||
platform/desktop/CCGLView.cpp
|
||||
platform/linux/CCImage.cpp
|
||||
platform/linux/CCDevice.cpp
|
||||
)
|
||||
|
@ -134,7 +134,7 @@ set(COCOS2D_SRC
|
|||
CCDeprecated.cpp
|
||||
platform/CCSAXParser.cpp
|
||||
platform/CCThread.cpp
|
||||
platform/CCEGLViewProtocol.cpp
|
||||
platform/CCGLViewProtocol.cpp
|
||||
platform/CCFileUtils.cpp
|
||||
../../external/edtaa3func/edtaa3func.cpp
|
||||
renderer/CCCustomCommand.cpp
|
||||
|
|
|
@ -154,42 +154,42 @@ THE SOFTWARE.
|
|||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
#include "platform/ios/CCApplication.h"
|
||||
#include "platform/ios/CCEGLView.h"
|
||||
#include "platform/ios/CCGLView.h"
|
||||
#include "platform/ios/CCGL.h"
|
||||
#include "platform/ios/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#include "platform/android/CCApplication.h"
|
||||
#include "platform/android/CCEGLView.h"
|
||||
#include "platform/android/CCGLView.h"
|
||||
#include "platform/android/CCGL.h"
|
||||
#include "platform/android/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
|
||||
#include "platform/blackberry/CCApplication.h"
|
||||
#include "platform/blackberry/CCEGLView.h"
|
||||
#include "platform/blackberry/CCGLView.h"
|
||||
#include "platform/blackberry/CCGL.h"
|
||||
#include "platform/blackberry/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#include "platform/win32/CCApplication.h"
|
||||
#include "platform/desktop/CCEGLView.h"
|
||||
#include "platform/desktop/CCGLView.h"
|
||||
#include "platform/win32/CCGL.h"
|
||||
#include "platform/win32/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#include "platform/mac/CCApplication.h"
|
||||
#include "platform/desktop/CCEGLView.h"
|
||||
#include "platform/desktop/CCGLView.h"
|
||||
#include "platform/mac/CCGL.h"
|
||||
#include "platform/mac/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
||||
#include "platform/linux/CCApplication.h"
|
||||
#include "platform/desktop/CCEGLView.h"
|
||||
#include "platform/desktop/CCGLView.h"
|
||||
#include "platform/linux/CCGL.h"
|
||||
#include "platform/linux/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
|
|
@ -304,11 +304,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClCompile Include="ccUtils.cpp" />
|
||||
<ClCompile Include="CCVertex.cpp" />
|
||||
<ClCompile Include="cocos2d.cpp" />
|
||||
<ClCompile Include="platform\CCEGLViewProtocol.cpp" />
|
||||
<ClCompile Include="platform\CCGLViewProtocol.cpp" />
|
||||
<ClCompile Include="platform\CCFileUtils.cpp" />
|
||||
<ClCompile Include="platform\CCSAXParser.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\CCCommon.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\CCCommon.h" />
|
||||
<ClInclude Include="platform\CCDevice.h" />
|
||||
<ClInclude Include="platform\CCEGLViewProtocol.h" />
|
||||
<ClInclude Include="platform\CCGLViewProtocol.h" />
|
||||
<ClInclude Include="platform\CCFileUtils.h" />
|
||||
<ClInclude Include="platform\CCImage.h" />
|
||||
<ClInclude Include="platform\CCImageCommon_cpp.h" />
|
||||
<ClInclude Include="platform\CCSAXParser.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\CCFileUtilsWin32.h" />
|
||||
<ClInclude Include="platform\win32\CCGL.h" />
|
||||
|
|
|
@ -363,7 +363,7 @@
|
|||
<ClCompile Include="platform\win32\CCStdC.cpp">
|
||||
<Filter>platform\win32</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\CCEGLViewProtocol.cpp">
|
||||
<ClCompile Include="platform\CCGLViewProtocol.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\CCFileUtils.cpp">
|
||||
|
@ -595,7 +595,7 @@
|
|||
<ClCompile Include="CCFontCharMap.cpp">
|
||||
<Filter>label_nodes</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\desktop\CCEGLView.cpp">
|
||||
<ClCompile Include="platform\desktop\CCGLView.cpp">
|
||||
<Filter>platform\desktop</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
@ -876,7 +876,7 @@
|
|||
<ClInclude Include="platform\CCDevice.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\CCEGLViewProtocol.h">
|
||||
<ClInclude Include="platform\CCGLViewProtocol.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\CCFileUtils.h">
|
||||
|
@ -1198,7 +1198,7 @@
|
|||
<ClInclude Include="CCFontCharMap.h">
|
||||
<Filter>label_nodes</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\desktop\CCEGLView.h">
|
||||
<ClInclude Include="platform\desktop\CCGLView.h">
|
||||
<Filter>platform\desktop</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -33,6 +33,8 @@ NS_CC_BEGIN
|
|||
* @{
|
||||
*/
|
||||
|
||||
class EAGLView;
|
||||
|
||||
class CC_DLL ApplicationProtocol
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -56,6 +56,7 @@ enum class LanguageType
|
|||
ITALIAN,
|
||||
GERMAN,
|
||||
SPANISH,
|
||||
DUTCH,
|
||||
RUSSIAN,
|
||||
KOREAN,
|
||||
JAPANESE,
|
||||
|
|
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCEGLViewProtocol.h"
|
||||
#include "CCGLViewProtocol.h"
|
||||
#include "CCTouch.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCSet.h"
|
||||
|
@ -71,24 +71,23 @@ namespace {
|
|||
|
||||
}
|
||||
|
||||
EGLViewProtocol::EGLViewProtocol()
|
||||
: _delegate(nullptr)
|
||||
, _scaleX(1.0f)
|
||||
GLViewProtocol::GLViewProtocol()
|
||||
: _scaleX(1.0f)
|
||||
, _scaleY(1.0f)
|
||||
, _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");
|
||||
|
||||
|
@ -107,17 +106,17 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut
|
|||
_scaleX = _scaleY = MAX(_scaleX, _scaleY);
|
||||
}
|
||||
|
||||
if (resolutionPolicy == ResolutionPolicy::SHOW_ALL)
|
||||
else if (resolutionPolicy == ResolutionPolicy::SHOW_ALL)
|
||||
{
|
||||
_scaleX = _scaleY = MIN(_scaleX, _scaleY);
|
||||
}
|
||||
|
||||
if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
|
||||
else if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
|
||||
_scaleX = _scaleY;
|
||||
_designResolutionSize.width = ceilf(_screenSize.width/_scaleX);
|
||||
}
|
||||
|
||||
if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
|
||||
else if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
|
||||
_scaleY = _scaleX;
|
||||
_designResolutionSize.height = ceilf(_screenSize.height/_scaleY);
|
||||
}
|
||||
|
@ -131,27 +130,28 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut
|
|||
_resolutionPolicy = resolutionPolicy;
|
||||
|
||||
// reset director's member variables to fit visible rect
|
||||
Director::getInstance()->_winSizeInPoints = getDesignResolutionSize();
|
||||
Director::getInstance()->createStatsLabel();
|
||||
Director::getInstance()->setGLDefaultValues();
|
||||
auto director = Director::getInstance();
|
||||
director->_winSizeInPoints = getDesignResolutionSize();
|
||||
director->createStatsLabel();
|
||||
director->setGLDefaultValues();
|
||||
}
|
||||
|
||||
const Size& EGLViewProtocol::getDesignResolutionSize() const
|
||||
const Size& GLViewProtocol::getDesignResolutionSize() const
|
||||
{
|
||||
return _designResolutionSize;
|
||||
}
|
||||
|
||||
const Size& EGLViewProtocol::getFrameSize() const
|
||||
const Size& GLViewProtocol::getFrameSize() const
|
||||
{
|
||||
return _screenSize;
|
||||
}
|
||||
|
||||
void EGLViewProtocol::setFrameSize(float width, float height)
|
||||
void GLViewProtocol::setFrameSize(float width, float height)
|
||||
{
|
||||
_designResolutionSize = _screenSize = Size(width, height);
|
||||
}
|
||||
|
||||
Size EGLViewProtocol::getVisibleSize() const
|
||||
Size GLViewProtocol::getVisibleSize() const
|
||||
{
|
||||
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ Size EGLViewProtocol::getVisibleSize() const
|
|||
}
|
||||
}
|
||||
|
||||
Point EGLViewProtocol::getVisibleOrigin() const
|
||||
Point GLViewProtocol::getVisibleOrigin() const
|
||||
{
|
||||
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
|
||||
{
|
||||
|
@ -176,12 +176,7 @@ Point EGLViewProtocol::getVisibleOrigin() const
|
|||
}
|
||||
}
|
||||
|
||||
void EGLViewProtocol::setTouchDelegate(EGLTouchDelegate * delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
void EGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
|
||||
void GLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
|
||||
{
|
||||
glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x),
|
||||
(GLint)(y * _scaleY + _viewPortRect.origin.y),
|
||||
|
@ -189,7 +184,7 @@ void EGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)
|
|||
(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),
|
||||
(GLint)(y * _scaleY + _viewPortRect.origin.y),
|
||||
|
@ -197,12 +192,12 @@ void EGLViewProtocol::setScissorInPoints(float x , float y , float w , float h)
|
|||
(GLsizei)(h * _scaleY));
|
||||
}
|
||||
|
||||
bool EGLViewProtocol::isScissorEnabled()
|
||||
bool GLViewProtocol::isScissorEnabled()
|
||||
{
|
||||
return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true;
|
||||
}
|
||||
|
||||
Rect EGLViewProtocol::getScissorRect() const
|
||||
Rect GLViewProtocol::getScissorRect() const
|
||||
{
|
||||
GLfloat params[4];
|
||||
glGetFloatv(GL_SCISSOR_BOX, params);
|
||||
|
@ -213,17 +208,17 @@ Rect EGLViewProtocol::getScissorRect() const
|
|||
return Rect(x, y, w, h);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::setViewName(const std::string& viewname )
|
||||
void GLViewProtocol::setViewName(const std::string& viewname )
|
||||
{
|
||||
_viewName = viewname;
|
||||
}
|
||||
|
||||
const std::string& EGLViewProtocol::getViewName() const
|
||||
const std::string& GLViewProtocol::getViewName() const
|
||||
{
|
||||
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;
|
||||
float x = 0.0f;
|
||||
|
@ -273,7 +268,7 @@ void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float y
|
|||
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;
|
||||
float x = 0.0f;
|
||||
|
@ -321,7 +316,7 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
|
|||
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;
|
||||
float x = 0.0f;
|
||||
|
@ -381,27 +376,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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
const Rect& EGLViewProtocol::getViewPortRect() const
|
||||
const Rect& GLViewProtocol::getViewPortRect() const
|
||||
{
|
||||
return _viewPortRect;
|
||||
}
|
||||
|
||||
float EGLViewProtocol::getScaleX() const
|
||||
float GLViewProtocol::getScaleX() const
|
||||
{
|
||||
return _scaleX;
|
||||
}
|
||||
|
||||
float EGLViewProtocol::getScaleY() const
|
||||
float GLViewProtocol::getScaleY() const
|
||||
{
|
||||
return _scaleY;
|
||||
}
|
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCEGLVIEWPROTOCOL_H__
|
||||
#define __CCEGLVIEWPROTOCOL_H__
|
||||
#ifndef __CCGLVIEWPROTOCOL_H__
|
||||
#define __CCGLVIEWPROTOCOL_H__
|
||||
|
||||
#include "ccTypes.h"
|
||||
#include "CCEventTouch.h"
|
||||
|
@ -65,18 +65,18 @@ class EGLTouchDelegate;
|
|||
* @{
|
||||
*/
|
||||
|
||||
class CC_DLL EGLViewProtocol
|
||||
class CC_DLL GLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLViewProtocol();
|
||||
GLViewProtocol();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLViewProtocol();
|
||||
virtual ~GLViewProtocol();
|
||||
|
||||
/** Force destroying EGL view, subclass must implement this method. */
|
||||
virtual void end() = 0;
|
||||
|
@ -133,9 +133,6 @@ public:
|
|||
*/
|
||||
virtual const Size& getDesignResolutionSize() const;
|
||||
|
||||
/** Set touch delegate */
|
||||
virtual void setTouchDelegate(EGLTouchDelegate * delegate);
|
||||
|
||||
/**
|
||||
* Set opengl view port rectangle with points.
|
||||
*/
|
||||
|
@ -184,8 +181,6 @@ public:
|
|||
protected:
|
||||
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]);
|
||||
|
||||
EGLTouchDelegate* _delegate;
|
||||
|
||||
// real screen size
|
||||
Size _screenSize;
|
||||
// resolution size, it is the size appropriate for the app resources.
|
||||
|
@ -205,4 +200,4 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* __CCEGLVIEWPROTOCOL_H__ */
|
||||
#endif /* __CCGLVIEWPROTOCOL_H__ */
|
|
@ -10,7 +10,7 @@ LOCAL_SRC_FILES := \
|
|||
CCApplication.cpp \
|
||||
CCCommon.cpp \
|
||||
CCDevice.cpp \
|
||||
CCEGLView.cpp \
|
||||
CCGLView.cpp \
|
||||
CCFileUtilsAndroid.cpp \
|
||||
CCImage.cpp \
|
||||
nativeactivity.cpp \
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "jni/JniHelper.h"
|
||||
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
|
||||
#include "CCApplication.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
#include <cstring>
|
||||
|
@ -116,6 +120,10 @@ LanguageType Application::getCurrentLanguage()
|
|||
{
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
else if (0 == strcmp("nl", pLanguageName))
|
||||
{
|
||||
ret = LanguageType::DUTCH;
|
||||
}
|
||||
else if (0 == strcmp("ko", pLanguageName))
|
||||
{
|
||||
ret = LanguageType::KOREAN;
|
||||
|
@ -157,3 +165,6 @@ void Application::applicationScreenSizeChanged(int newWidth, int newHeight) {
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __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/CCApplicationProtocol.h"
|
||||
|
||||
|
@ -87,4 +91,6 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif // __CC_APPLICATION_ANDROID_H__
|
||||
|
|
|
@ -23,6 +23,9 @@ 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_ANDROID
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
|
||||
#include <android/log.h>
|
||||
|
@ -44,3 +47,6 @@ void LuaLog(const char * pszFormat)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "platform/CCDevice.h"
|
||||
#include "jni/DPIJni.h"
|
||||
#include "nativeactivity.h"
|
||||
|
@ -56,3 +60,6 @@ void Device::setAccelerometerInterval(float interval)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "CCFileUtilsAndroid.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
|
||||
|
@ -353,3 +357,5 @@ string FileUtilsAndroid::getWritablePath() const
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
|
|
@ -25,6 +25,9 @@ Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|||
#ifndef __CC_FILEUTILS_ANDROID_H__
|
||||
#define __CC_FILEUTILS_ANDROID_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "ccTypes.h"
|
||||
|
@ -86,4 +89,6 @@ private:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif // __CC_FILEUTILS_ANDROID_H__
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CCGL_H__
|
||||
#define __CCGL_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#define glClearDepth glClearDepthf
|
||||
#define glDeleteVertexArrays glDeleteVertexArraysOES
|
||||
#define glGenVertexArrays glGenVertexArraysOES
|
||||
|
@ -63,4 +66,6 @@ extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT;
|
|||
#define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT
|
||||
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif // __CCGL_H__
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "CCEGLView.h"
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "CCGLView.h"
|
||||
#include "CCSet.h"
|
||||
#include "CCDirector.h"
|
||||
#include "ccMacros.h"
|
||||
|
@ -48,46 +52,79 @@ void initExtensions() {
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void EGLView::end()
|
||||
void GLView::end()
|
||||
{
|
||||
terminateProcessJNI();
|
||||
}
|
||||
|
||||
void EGLView::swapBuffers()
|
||||
void GLView::swapBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
EGLView* EGLView::getInstance()
|
||||
{
|
||||
static EGLView instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
EGLView* EGLView::sharedOpenGLView()
|
||||
{
|
||||
return EGLView::getInstance();
|
||||
}
|
||||
|
||||
void EGLView::setIMEKeyboardState(bool bOpen)
|
||||
void GLView::setIMEKeyboardState(bool bOpen)
|
||||
{
|
||||
setKeyboardStateJNI((int)bOpen);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
|
@ -26,41 +26,40 @@ THE SOFTWARE.
|
|||
#ifndef __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 "platform/CCEGLViewProtocol.h"
|
||||
#include "platform/CCGLViewProtocol.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
class CC_DLL GLView : public Object, public GLViewProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
EGLView();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~EGLView();
|
||||
|
||||
bool isOpenGLReady();
|
||||
|
||||
// keep compatible
|
||||
void end();
|
||||
void swapBuffers();
|
||||
void setIMEKeyboardState(bool bOpen);
|
||||
|
||||
// static function
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
static EGLView* getInstance();
|
||||
static GLView* create(const std::string &viewname);
|
||||
static GLView* createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor = 1.0f);
|
||||
static GLView* createWithFullScreen(const std::string& viewName);
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
||||
bool isOpenGLReady() override;
|
||||
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
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif // end of __CC_EGLVIEW_ANDROID_H__
|
||||
|
|
@ -23,7 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
//#define COCOS2D_DEBUG 1
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#define __CC_PLATFORM_IMAGE_CPP__
|
||||
#include "platform/CCImageCommon_cpp.h"
|
||||
|
@ -246,3 +247,5 @@ extern "C"
|
|||
env->GetByteArrayRegion(pixels, 0, size, (jbyte*)bitmapDC._data);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "android/log.h"
|
||||
|
||||
#define CC_DLL
|
||||
|
@ -59,4 +62,6 @@ THE SOFTWARE.
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_STD_C_H__
|
||||
#define __CC_STD_C_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
@ -45,4 +48,6 @@ THE SOFTWARE.
|
|||
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
|
||||
#endif // MAX
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif // __CC_STD_C_H__
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "nativeactivity.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
@ -43,7 +47,7 @@ THE SOFTWARE.
|
|||
#include "CCFileUtilsAndroid.h"
|
||||
#include "jni/JniHelper.h"
|
||||
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
#include "CCDrawingPrimitives.h"
|
||||
#include "CCShaderCache.h"
|
||||
#include "CCTextureCache.h"
|
||||
|
@ -115,8 +119,6 @@ extern "C" {
|
|||
jsize size = env->GetArrayLength(text);
|
||||
pthread_mutex_lock(&(engine.app->mutex));
|
||||
if (size > 0) {
|
||||
|
||||
|
||||
jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0);
|
||||
char* pBuf = (char*)malloc(size+1);
|
||||
if (pBuf != NULL) {
|
||||
|
@ -141,17 +143,21 @@ typedef struct cocos_dimensions {
|
|||
int h;
|
||||
} 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(...)");
|
||||
pthread_t thisthread = pthread_self();
|
||||
LOGI("pthread_self() = %X", thisthread);
|
||||
|
||||
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();
|
||||
view->setFrameSize(d.w, d.h);
|
||||
glview = cocos2d::GLView::create("Android app");
|
||||
glview->setFrameSize(d.w, d.h);
|
||||
director->setOpenGLView(glview);
|
||||
|
||||
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::DrawPrimitives::init();
|
||||
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
||||
|
||||
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
|
||||
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent);
|
||||
cocos2d::Director::getInstance()->setGLDefaultValues();
|
||||
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
|
||||
director->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
r.w = -1;
|
||||
r.h = -1;
|
||||
|
@ -245,6 +253,7 @@ static cocos_dimensions engine_init_display(struct engine* engine) {
|
|||
r.w = w;
|
||||
r.h = h;
|
||||
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -275,7 +284,8 @@ static void dispatch_pending_runnables() {
|
|||
/**
|
||||
* 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(...)");
|
||||
pthread_t thisthread = pthread_self();
|
||||
LOG_RENDER_DEBUG("pthread_self() = %X", thisthread);
|
||||
|
@ -308,7 +318,8 @@ static void engine_draw_frame(struct engine* engine) {
|
|||
/**
|
||||
* 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) {
|
||||
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
if (engine->context != EGL_NO_CONTEXT) {
|
||||
|
@ -533,7 +544,8 @@ void setAccelerometerIntervalJni(float interval) {
|
|||
/**
|
||||
* 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;
|
||||
switch (cmd) {
|
||||
case APP_CMD_SAVE_STATE:
|
||||
|
@ -598,10 +610,10 @@ static void onContentRectChanged(ANativeActivity* activity, const ARect* rect) {
|
|||
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;
|
||||
int processed = 0;
|
||||
while (AInputQueue_hasEvents( app->inputQueue ) && AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
|
||||
while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
|
||||
LOGV("New input event: type=%d\n", AInputEvent_getType(event));
|
||||
if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
|
||||
continue;
|
||||
|
@ -609,10 +621,6 @@ static void process_input(struct android_app* app, struct android_poll_source* s
|
|||
int32_t handled = 0;
|
||||
if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
|
||||
AInputQueue_finishEvent(app->inputQueue, event, handled);
|
||||
processed = 1;
|
||||
}
|
||||
if (processed == 0) {
|
||||
LOGE("Failure reading next input event: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -751,3 +759,5 @@ void android_main(struct android_app* state) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
|
|
@ -24,6 +24,9 @@ THE SOFTWARE.
|
|||
#ifndef __COCOSNATIVEACTIVITY_H__
|
||||
#define __COCOSNATIVEACTIVITY_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
/**
|
||||
* This is the interface to the Android native activity
|
||||
*/
|
||||
|
@ -32,4 +35,6 @@ void enableAccelerometerJni(void);
|
|||
void disableAccelerometerJni(void);
|
||||
void setAccelerometerIntervalJni(float interval);
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#endif // __COCOSNATIVEACTIVITY_H__
|
||||
|
|
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -176,8 +176,8 @@ static keyCodeItem g_keyCodeStructArray[] = {
|
|||
};
|
||||
|
||||
|
||||
//begin EGLViewEventHandler
|
||||
class EGLViewEventHandler
|
||||
//begin GLViewEventHandler
|
||||
class GLViewEventHandler
|
||||
{
|
||||
public:
|
||||
static bool s_captured;
|
||||
|
@ -194,18 +194,18 @@ public:
|
|||
static void onGLFWframebuffersize(GLFWwindow* window, int w, int h);
|
||||
};
|
||||
|
||||
bool EGLViewEventHandler::s_captured = false;
|
||||
float EGLViewEventHandler::s_mouseX = 0;
|
||||
float EGLViewEventHandler::s_mouseY = 0;
|
||||
bool GLViewEventHandler::s_captured = false;
|
||||
float GLViewEventHandler::s_mouseX = 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);
|
||||
}
|
||||
|
||||
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(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 (eglView->isRetina()) {
|
||||
|
@ -278,9 +278,9 @@ void EGLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
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;
|
||||
|
||||
EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL);
|
||||
|
@ -290,7 +290,7 @@ void EGLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x
|
|||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
void EGLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
|
||||
void GLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y)
|
||||
{
|
||||
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 frameSizeH = view->getFrameSize().height;
|
||||
|
@ -334,16 +334,48 @@ 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)
|
||||
, _frameZoomFactor(1.0f)
|
||||
, _supportTouch(false)
|
||||
|
@ -351,32 +383,26 @@ EGLView::EGLView()
|
|||
, _mainWindow(nullptr)
|
||||
, _primaryMonitor(nullptr)
|
||||
{
|
||||
CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n");
|
||||
_viewName = "cocos2dx";
|
||||
s_pEglView = this;
|
||||
g_keyCodeMap.clear();
|
||||
for (auto& item : g_keyCodeStructArray)
|
||||
{
|
||||
g_keyCodeMap[item.glfwKeyCode] = item.keyCode;
|
||||
}
|
||||
glfwSetErrorCallback(EGLViewEventHandler::onGLFWError);
|
||||
glfwSetErrorCallback(GLViewEventHandler::onGLFWError);
|
||||
glfwInit();
|
||||
}
|
||||
|
||||
EGLView::~EGLView()
|
||||
GLView::~GLView()
|
||||
{
|
||||
CCLOGINFO("deallocing EGLView: %p", this);
|
||||
CCLOGINFO("deallocing GLView: %p", this);
|
||||
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);
|
||||
setFrameSize(width, height);
|
||||
setFrameSize(rect.size.width, rect.size.height);
|
||||
setFrameZoomFactor(frameZoomFactor);
|
||||
|
||||
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
||||
|
@ -397,16 +423,16 @@ bool EGLView::init(const std::string& viewName, float width, float height, float
|
|||
{
|
||||
_isRetina = true;
|
||||
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);
|
||||
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseMoveCallBack);
|
||||
glfwSetScrollCallback(_mainWindow, EGLViewEventHandler::onGLFWMouseScrollCallback);
|
||||
glfwSetCharCallback(_mainWindow, EGLViewEventHandler::onGLFWCharCallback);
|
||||
glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::onGLFWKeyCallback);
|
||||
glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::onGLFWWindowPosCallback);
|
||||
glfwSetFramebufferSizeCallback(_mainWindow, EGLViewEventHandler::onGLFWframebuffersize);
|
||||
glfwSetMouseButtonCallback(_mainWindow, GLViewEventHandler::onGLFWMouseCallBack);
|
||||
glfwSetCursorPosCallback(_mainWindow, GLViewEventHandler::onGLFWMouseMoveCallBack);
|
||||
glfwSetScrollCallback(_mainWindow, GLViewEventHandler::onGLFWMouseScrollCallback);
|
||||
glfwSetCharCallback(_mainWindow, GLViewEventHandler::onGLFWCharCallback);
|
||||
glfwSetKeyCallback(_mainWindow, GLViewEventHandler::onGLFWKeyCallback);
|
||||
glfwSetWindowPosCallback(_mainWindow, GLViewEventHandler::onGLFWWindowPosCallback);
|
||||
glfwSetFramebufferSizeCallback(_mainWindow, GLViewEventHandler::onGLFWframebuffersize);
|
||||
// check OpenGL version at first
|
||||
const GLubyte* glVersion = glGetString(GL_VERSION);
|
||||
|
||||
|
@ -428,34 +454,34 @@ bool EGLView::init(const std::string& viewName, float width, float height, float
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EGLView::initWithFullScreen(const std::string& viewName)
|
||||
bool GLView::initWithFullScreen(const std::string& viewName)
|
||||
{
|
||||
_primaryMonitor = glfwGetPrimaryMonitor();
|
||||
if (nullptr == _primaryMonitor)
|
||||
return false;
|
||||
|
||||
const GLFWvidmode* videoMode = glfwGetVideoMode(_primaryMonitor);
|
||||
return init(viewName, videoMode->width, videoMode->height, 1.0f);
|
||||
return initWithRect(viewName, Rect(0, 0, videoMode->width, videoMode->height), 1.0f);
|
||||
}
|
||||
|
||||
bool EGLView::isOpenGLReady()
|
||||
bool GLView::isOpenGLReady()
|
||||
{
|
||||
return nullptr != _mainWindow;
|
||||
}
|
||||
|
||||
void EGLView::end()
|
||||
void GLView::end()
|
||||
{
|
||||
if(_mainWindow)
|
||||
glfwSetWindowShouldClose(_mainWindow,1);
|
||||
}
|
||||
|
||||
void EGLView::swapBuffers()
|
||||
void GLView::swapBuffers()
|
||||
{
|
||||
if(_mainWindow)
|
||||
glfwSwapBuffers(_mainWindow);
|
||||
}
|
||||
|
||||
bool EGLView::windowShouldClose()
|
||||
bool GLView::windowShouldClose()
|
||||
{
|
||||
if(_mainWindow)
|
||||
return glfwWindowShouldClose(_mainWindow);
|
||||
|
@ -463,33 +489,33 @@ bool EGLView::windowShouldClose()
|
|||
return true;
|
||||
}
|
||||
|
||||
void EGLView::pollEvents()
|
||||
void GLView::pollEvents()
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
void EGLView::setIMEKeyboardState(bool /*bOpen*/)
|
||||
void GLView::setIMEKeyboardState(bool /*bOpen*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EGLView::setFrameZoomFactor(float zoomFactor)
|
||||
void GLView::setFrameZoomFactor(float zoomFactor)
|
||||
{
|
||||
_frameZoomFactor = zoomFactor;
|
||||
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
|
||||
}
|
||||
|
||||
float EGLView::getFrameZoomFactor()
|
||||
float GLView::getFrameZoomFactor()
|
||||
{
|
||||
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),
|
||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
||||
|
@ -497,7 +523,7 @@ void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
|||
(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),
|
||||
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
|
||||
|
@ -505,18 +531,6 @@ void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
|||
(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)
|
||||
static bool glew_dynamic_binding()
|
||||
{
|
||||
|
@ -582,7 +596,7 @@ static bool glew_dynamic_binding()
|
|||
#endif
|
||||
|
||||
// helper
|
||||
bool EGLView::initGlew()
|
||||
bool GLView::initGlew()
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
|
||||
GLenum GlewInitResult = glewInit();
|
|
@ -26,52 +26,29 @@ THE SOFTWARE.
|
|||
#ifndef __CC_EGLVIEW_DESKTOP_H__
|
||||
#define __CC_EGLVIEW_DESKTOP_H__
|
||||
|
||||
#include "CCObject.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCEGLViewProtocol.h"
|
||||
#include "platform/CCGLViewProtocol.h"
|
||||
#include "glfw3.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL EGLView : public EGLViewProtocol
|
||||
class CC_DLL GLView : public Object, public GLViewProtocol
|
||||
{
|
||||
public:
|
||||
// static function
|
||||
/**
|
||||
@brief get the shared main open gl window
|
||||
*/
|
||||
static EGLView* getInstance();
|
||||
static GLView* create(const std::string& viewName);
|
||||
static GLView* createWithRect(const std::string& viewName, Rect size, float frameZoomFactor = 1.0f);
|
||||
static GLView* createWithFullScreen(const std::string& viewName);
|
||||
|
||||
/** @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.
|
||||
*/
|
||||
bool init(const std::string& viewName, float width, float height, float frameZoomFactor = 1.0f);
|
||||
bool initWithFullScreen(const std::string& viewName);
|
||||
|
||||
//void resize(int width, int height);
|
||||
|
||||
float getFrameZoomFactor();
|
||||
//void centerWindow();
|
||||
|
||||
|
||||
virtual void setViewPortInPoints(float x , float y , float w , float h);
|
||||
virtual void setScissorInPoints(float x , float y , float w , float h);
|
||||
|
||||
|
@ -80,7 +57,20 @@ public:
|
|||
void pollEvents();
|
||||
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:
|
||||
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.
|
||||
*/
|
||||
|
@ -93,11 +83,13 @@ protected:
|
|||
bool _isRetina;
|
||||
|
||||
float _frameZoomFactor;
|
||||
static EGLView* s_pEglView;
|
||||
|
||||
GLFWwindow* _mainWindow;
|
||||
GLFWmonitor* _primaryMonitor;
|
||||
friend class EGLViewEventHandler;
|
||||
friend class GLViewEventHandler;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(GLView);
|
||||
};
|
||||
|
||||
NS_CC_END // end of namespace cocos2d
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __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/CCApplicationProtocol.h"
|
||||
|
||||
|
@ -90,4 +93,6 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#endif // end of __CC_APPLICATION_IOS_H__
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#import "CCApplication.h"
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "CCGeometry.h"
|
||||
|
@ -108,6 +110,9 @@ LanguageType Application::getCurrentLanguage()
|
|||
else if ([languageCode isEqualToString:@"es"]){
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"nl"]){
|
||||
ret = LanguageType::DUTCH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ru"]){
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
|
@ -152,3 +157,5 @@ void Application::applicationScreenSizeChanged(int newWidth, int newHeight) {
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
@ -54,3 +57,5 @@ void LuaLog(const char * format)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
|
@ -22,6 +22,11 @@
|
|||
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
|
||||
|
||||
#include "CCDevice.h"
|
||||
#include "ccTypes.h"
|
||||
#include "CCEventDispatcher.h"
|
||||
|
@ -174,3 +179,5 @@ void Device::setAccelerometerInterval(float interval)
|
|||
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -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 <OpenGLES/EAGL.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 */
|
||||
+ (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 */
|
||||
- (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 */
|
||||
|
@ -155,3 +155,5 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
-(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis;
|
||||
-(void) doAnimationWhenAnotherEditBeClicked;
|
||||
@end
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
|
@ -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 "CCEGLView.h"
|
||||
#import "EAGLView.h"
|
||||
#import "CCGLView.h"
|
||||
#import "CCEAGLView.h"
|
||||
#import "CCES2Renderer.h"
|
||||
#import "CCDirector.h"
|
||||
#import "CCSet.h"
|
||||
#import "CCTouch.h"
|
||||
#import "CCIMEDispatcher.h"
|
||||
#import "OpenGL_Internal.h"
|
||||
#import "CCEGLView.h"
|
||||
#import "CCGLView.h"
|
||||
//CLASS IMPLEMENTATIONS:
|
||||
|
||||
#define IOS_MAX_TOUCHES_COUNT 10
|
||||
|
||||
static CCEAGLView *__view = 0;
|
||||
|
||||
@interface CCEAGLView (Private)
|
||||
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
|
||||
- (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];
|
||||
}
|
||||
|
||||
+ (id) sharedEGLView
|
||||
{
|
||||
return __view;
|
||||
}
|
||||
|
||||
- (id) initWithFrame:(CGRect)frame
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -409,11 +402,13 @@ static CCEAGLView *__view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
|
||||
++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
|
||||
|
@ -429,11 +424,13 @@ static CCEAGLView *__view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
|
||||
++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
|
||||
|
@ -450,11 +447,13 @@ static CCEAGLView *__view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
|
||||
++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
|
||||
|
@ -471,11 +470,13 @@ static CCEAGLView *__view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;;
|
||||
++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
|
||||
|
@ -795,8 +796,9 @@ static CCEAGLView *__view = 0;
|
|||
break;
|
||||
}
|
||||
|
||||
float scaleX = cocos2d::EGLView::getInstance()->getScaleX();
|
||||
float scaleY = cocos2d::EGLView::getInstance()->getScaleY();
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
float scaleX = glview->getScaleX();
|
||||
float scaleY = glview->getScaleY();
|
||||
|
||||
|
||||
if (self.contentScaleFactor == 2.0f)
|
||||
|
@ -807,7 +809,7 @@ static CCEAGLView *__view = 0;
|
|||
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);
|
||||
if (offestY < 0.0f)
|
||||
{
|
||||
|
@ -866,11 +868,12 @@ static CCEAGLView *__view = 0;
|
|||
[UIView setAnimationDuration:duration];
|
||||
[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;
|
||||
|
||||
dis *= cocos2d::EGLView::getInstance()->getScaleY();
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
dis *= glview->getScaleY();
|
||||
|
||||
if (self.contentScaleFactor == 2.0f)
|
||||
{
|
||||
|
@ -912,3 +915,5 @@ static CCEAGLView *__view = 0;
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
|
@ -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__
|
|
@ -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
|
||||
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
// 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.
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#import "CCPlatformMacros.h"
|
||||
#import "CCESRenderer.h"
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
|
@ -76,4 +80,4 @@
|
|||
@end
|
||||
|
||||
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -28,8 +28,11 @@
|
|||
// 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.
|
||||
|
||||
#import "CCPlatformMacros.h"
|
||||
#import "CCES2Renderer.h"
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#import "CCPlatformMacros.h"
|
||||
#import "OpenGL_Internal.h"
|
||||
|
||||
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
|
||||
|
@ -251,3 +254,5 @@
|
|||
|
||||
@end
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
// 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.
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
|
@ -48,3 +52,4 @@
|
|||
- (unsigned int) msaaColorBuffer;
|
||||
@end
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __PLATFORM_IOS_CCGL_H__
|
||||
#define __PLATFORM_IOS_CCGL_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#define glClearDepth glClearDepthf
|
||||
#define glDeleteVertexArrays glDeleteVertexArraysOES
|
||||
#define glGenVertexArrays glGenVertexArraysOES
|
||||
|
@ -39,5 +42,7 @@ THE SOFTWARE.
|
|||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#endif // __PLATFORM_IOS_CCGL_H__
|
||||
|
||||
|
|
|
@ -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__
|
|
@ -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
|
||||
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#include "CCImageCommon_cpp.h"
|
||||
|
||||
#import "CCImage.h"
|
||||
|
@ -468,3 +472,5 @@ bool Image::saveToFile(const std::string& filename, bool isToRGB)
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ THE SOFTWARE.
|
|||
#ifndef __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define CC_DLL
|
||||
|
@ -44,5 +47,6 @@ THE SOFTWARE.
|
|||
#endif
|
||||
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_STD_C_H__
|
||||
#define __CC_STD_C_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
@ -45,4 +48,5 @@ THE SOFTWARE.
|
|||
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
|
||||
#endif // MAX
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
#endif // __CC_STD_C_H__
|
||||
|
|
|
@ -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 */
|
||||
#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
|
||||
#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__); }
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
// when compiling to ARM (iPhone device), hide everything and use system defaults
|
||||
|
@ -73,4 +77,6 @@ THE SOFTWARE.
|
|||
|
||||
@end
|
||||
|
||||
#endif
|
||||
#endif // !TARGET_CPU_ARM
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -26,6 +26,8 @@ THE SOFTWARE.
|
|||
|
||||
#import "AccelerometerSimulation.h"
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
||||
// 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 !TARGET_CPU_ARM
|
||||
|
@ -263,4 +265,6 @@ static CCAccelerometerSimulation *sharedAccelerometer = NULL;
|
|||
}
|
||||
@end
|
||||
|
||||
#endif
|
||||
#endif // !TARGET_CPU_ARM
|
||||
|
||||
#endif // CC_PLATFORM_IOS
|
||||
|
|
|
@ -23,13 +23,16 @@ 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_LINUX
|
||||
|
||||
#include "CCApplication.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <string>
|
||||
#include "CCDirector.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -67,13 +70,14 @@ int Application::run()
|
|||
return 0;
|
||||
}
|
||||
|
||||
EGLView* pMainWnd = EGLView::getInstance();
|
||||
auto director = Director::getInstance();
|
||||
auto glview = director->getOpenGLView();
|
||||
|
||||
while (!pMainWnd->windowShouldClose())
|
||||
while (!glview->windowShouldClose())
|
||||
{
|
||||
long iLastTime = getCurrentMillSecond();
|
||||
Director::getInstance()->mainLoop();
|
||||
pMainWnd->pollEvents();
|
||||
director->mainLoop();
|
||||
glview->pollEvents();
|
||||
long iCurTime = getCurrentMillSecond();
|
||||
if (iCurTime-iLastTime<_animationInterval){
|
||||
usleep((_animationInterval - iCurTime+iLastTime)*1000);
|
||||
|
@ -84,8 +88,8 @@ int Application::run()
|
|||
* when we want to close the window, we should call Director::end();
|
||||
* then call Director::mainLoop to do release of internal resources
|
||||
*/
|
||||
Director::getInstance()->end();
|
||||
Director::getInstance()->mainLoop();
|
||||
director->end();
|
||||
director->mainLoop();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -171,6 +175,10 @@ LanguageType Application::getCurrentLanguage()
|
|||
{
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if (0 == strcmp("nl", pLanguageName))
|
||||
{
|
||||
ret = LanguageType::DUTCH;
|
||||
}
|
||||
else if (0 == strcmp("ru", pLanguageName))
|
||||
{
|
||||
ret = LanguageType::RUSSIAN;
|
||||
|
@ -208,3 +216,6 @@ LanguageType Application::getCurrentLanguage()
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef CCAPLICATION_H_
|
||||
#define CCAPLICATION_H_
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCApplicationProtocol.h"
|
||||
#include <string>
|
||||
|
@ -94,4 +97,6 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#endif /* CCAPLICATION_H_ */
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "CCStdC.h"
|
||||
#include "CCConsole.h"
|
||||
|
@ -39,3 +43,5 @@ void LuaLog(const char * format)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "platform/CCDevice.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -64,3 +68,5 @@ void Device::setAccelerometerInterval(float interval)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "CCFileUtilsLinux.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "ccMacros.h"
|
||||
|
@ -114,3 +118,5 @@ bool FileUtilsLinux::isFileExist(const std::string& strFilePath) const
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
|
|
@ -25,6 +25,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_FILEUTILS_LINUX_H__
|
||||
#define __CC_FILEUTILS_LINUX_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "ccTypes.h"
|
||||
|
@ -56,5 +59,6 @@ public:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CC_FILEUTILS_LINUX_H__
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#endif // __CC_FILEUTILS_LINUX_H__
|
||||
|
|
|
@ -25,8 +25,13 @@ THE SOFTWARE.
|
|||
#ifndef __CCGL_H__
|
||||
#define __CCGL_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#endif // __CCGL_H__
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -486,3 +490,5 @@ bool Image::initWithString(
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_USRDLL)
|
||||
|
@ -47,5 +51,6 @@ THE SOFTWARE.
|
|||
#endif
|
||||
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
||||
|
|
|
@ -23,6 +23,9 @@ 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_LINUX
|
||||
|
||||
#include "CCStdC.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
|
@ -65,5 +68,6 @@ int CC_DLL gettimeofday(struct timeval * val, struct timezone *)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_STD_C_H__
|
||||
#define __CC_STD_C_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
|
||||
#include <float.h>
|
||||
|
@ -52,4 +55,6 @@ THE SOFTWARE.
|
|||
#define cosf cos
|
||||
#define sinf sin
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
|
||||
#endif // __CC_STD_C_H__
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __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/CCApplicationProtocol.h"
|
||||
#include <string>
|
||||
|
@ -52,7 +55,7 @@ public:
|
|||
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
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#endif // end of __CC_APPLICATION_MAC_H__;
|
||||
|
|
|
@ -23,6 +23,9 @@ 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_MAC
|
||||
|
||||
#import "CCApplication.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <algorithm>
|
||||
|
@ -30,7 +33,7 @@ THE SOFTWARE.
|
|||
#include "CCGeometry.h"
|
||||
#include "CCDirector.h"
|
||||
#import "CCDirectorCaller.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -54,12 +57,12 @@ int Application::run()
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
EGLView* pMainWnd = EGLView::getInstance();
|
||||
GLView* glview = Director::getInstance()->getOpenGLView();
|
||||
|
||||
while (!pMainWnd->windowShouldClose())
|
||||
while (!glview->windowShouldClose())
|
||||
{
|
||||
Director::getInstance()->mainLoop();
|
||||
pMainWnd->pollEvents();
|
||||
glview->pollEvents();
|
||||
}
|
||||
|
||||
/* Only work on Desktop
|
||||
|
@ -130,6 +133,9 @@ LanguageType Application::getCurrentLanguage()
|
|||
else if ([languageCode isEqualToString:@"es"]){
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"nl"]){
|
||||
ret = LanguageType::DUTCH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ru"]){
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
|
@ -189,3 +195,5 @@ const std::string& Application::getStartupScriptFilename(void)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
#include "CCDirector.h"
|
||||
#include "CCGLView.h"
|
||||
|
||||
#define GLFW_EXPOSE_NATIVE_NSGL
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#include "glfw3native.h"
|
||||
|
@ -51,7 +58,8 @@ void MessageBox(const char * msg, const char * title)
|
|||
[alert setInformativeText:tmpTitle];
|
||||
[alert setAlertStyle:NSWarningAlertStyle];
|
||||
|
||||
id window = glfwGetCocoaWindow(EGLView::getInstance()->getWindow());
|
||||
GLView* glview = Director::getInstance()->getOpenGLView();
|
||||
id window = glfwGetCocoaWindow(glview->getWindow());
|
||||
[alert beginSheetModalForWindow:window
|
||||
modalDelegate:[window delegate]
|
||||
didEndSelector:nil
|
||||
|
@ -59,3 +67,6 @@ void MessageBox(const char * msg, const char * title)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#include "platform/CCDevice.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -43,3 +47,5 @@ void Device::setAccelerometerInterval(float interval)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <QuartzCore/CVDisplayLink.h>
|
||||
|
||||
|
@ -38,3 +42,5 @@ THE SOFTWARE.
|
|||
|
||||
+(id) sharedDirectorCaller;
|
||||
@end
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
|
|
@ -23,6 +23,9 @@ 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_MAC
|
||||
|
||||
#import "CCDirectorCaller.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCAutoreleasePool.h"
|
||||
|
@ -200,3 +203,5 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif //s CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __PLATFORM_MAC_CCGL_H__
|
||||
#define __PLATFORM_MAC_CCGL_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#import <OpenGL/gl.h>
|
||||
#import <OpenGL/glu.h>
|
||||
#import <OpenGL/glext.h>
|
||||
|
@ -42,3 +45,5 @@ THE SOFTWARE.
|
|||
|
||||
|
||||
#endif // __PLATFORM_MAC_CCGL_H__
|
||||
|
||||
#endif //s CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
|
|
@ -23,6 +23,9 @@ 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_MAC
|
||||
|
||||
#include "CCImageCommon_cpp.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
@ -231,3 +234,4 @@ bool Image::initWithString(
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define CC_DLL
|
||||
|
@ -47,6 +50,6 @@ THE SOFTWARE.
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_STD_C_H__
|
||||
#define __CC_STD_C_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
@ -45,4 +48,6 @@ THE SOFTWARE.
|
|||
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
|
||||
#endif // MAX
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#endif // __CC_STD_C_H__
|
||||
|
|
|
@ -22,8 +22,12 @@ 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_WIN32
|
||||
|
||||
#include "CCApplication.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCGLView.h"
|
||||
#include "CCDirector.h"
|
||||
#include <algorithm>
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
@ -72,16 +76,17 @@ int Application::run()
|
|||
return 0;
|
||||
}
|
||||
|
||||
EGLView* pMainWnd = EGLView::getInstance();
|
||||
auto director = Director::getInstance();
|
||||
auto glview = director->getOpenGLView();
|
||||
|
||||
while(!pMainWnd->windowShouldClose())
|
||||
while(!glview->windowShouldClose())
|
||||
{
|
||||
QueryPerformanceCounter(&nNow);
|
||||
if (nNow.QuadPart - nLast.QuadPart > _animationInterval.QuadPart)
|
||||
{
|
||||
nLast.QuadPart = nNow.QuadPart;
|
||||
Director::getInstance()->mainLoop();
|
||||
pMainWnd->pollEvents();
|
||||
director->mainLoop();
|
||||
glview->pollEvents();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -94,8 +99,8 @@ int Application::run()
|
|||
* when we want to close the window, we should call Director::end();
|
||||
* then call Director::mainLoop to do release of internal resources
|
||||
*/
|
||||
Director::getInstance()->end();
|
||||
Director::getInstance()->mainLoop();
|
||||
director->end();
|
||||
director->mainLoop();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -148,6 +153,9 @@ LanguageType Application::getCurrentLanguage()
|
|||
case LANG_SPANISH:
|
||||
ret = LanguageType::SPANISH;
|
||||
break;
|
||||
case LANG_DUTCH:
|
||||
ret = LanguageType::DUTCH;
|
||||
break;
|
||||
case LANG_RUSSIAN:
|
||||
ret = LanguageType::RUSSIAN;
|
||||
break;
|
||||
|
@ -245,3 +253,5 @@ static void PVRFrameEnableControlWindow(bool bEnable)
|
|||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
|
|
@ -25,6 +25,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_APPLICATION_WIN32_H__
|
||||
#define __CC_APPLICATION_WIN32_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#include "CCStdC.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCApplicationProtocol.h"
|
||||
|
@ -101,4 +104,6 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#endif // __CC_APPLICATION_WIN32_H__
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "CCStdC.h"
|
||||
|
||||
|
@ -55,3 +59,5 @@ void LuaLog(const char *pszMsg)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#include "platform/CCDevice.h"
|
||||
#include "CCStdC.h"
|
||||
|
||||
|
@ -48,3 +52,5 @@ void Device::setAccelerometerInterval(float interval)
|
|||
{}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
|
|
@ -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
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#include "CCFileUtilsWin32.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include <Shlobj.h>
|
||||
|
@ -303,3 +307,6 @@ string FileUtilsWin32::getWritablePath() const
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_FILEUTILS_WIN32_H__
|
||||
#define __CC_FILEUTILS_WIN32_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "ccTypes.h"
|
||||
|
@ -101,5 +104,7 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#endif // __CC_FILEUTILS_WIN32_H__
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CCGL_H__
|
||||
#define __CCGL_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
||||
|
@ -36,4 +39,6 @@ THE SOFTWARE.
|
|||
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
|
||||
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#endif // __CCGL_H__
|
||||
|
|
|
@ -23,6 +23,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#define __CC_PLATFORM_IMAGE_CPP__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#if _MSC_VER
|
||||
#include <cctype>
|
||||
#endif
|
||||
|
@ -440,3 +444,5 @@ bool Image::initWithString(
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
|
|
@ -25,6 +25,9 @@ THE SOFTWARE.
|
|||
#ifndef __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
@ -55,6 +58,6 @@ THE SOFTWARE.
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif //s CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
||||
|
|
|
@ -25,6 +25,9 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCStdC.h"
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#ifndef __MINGW32__
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -45,3 +48,5 @@ int gettimeofday(struct timeval * val, struct timezone *)
|
|||
NS_CC_END
|
||||
|
||||
#endif // __MINGW32__
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
|
|
@ -26,6 +26,9 @@ THE SOFTWARE.
|
|||
#ifndef __CC_STD_C_H__
|
||||
#define __CC_STD_C_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
//typedef SSIZE_T ssize_t;
|
||||
// ssize_t was redefined as int in libwebsockets.h.
|
||||
// Therefore, to avoid conflict, we needs the same definition.
|
||||
|
@ -151,5 +154,9 @@ inline errno_t strcpy_s(char *strDestination, size_t numberOfElements,
|
|||
#undef min
|
||||
#undef max
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#endif // __CC_STD_C_H__
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -29,13 +29,16 @@
|
|||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
@ -243,5 +246,6 @@ typedef uint64_t uintmax_t;
|
|||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
||||
|
|
|
@ -158,10 +158,8 @@ static void _log(const char *format, va_list args)
|
|||
WCHAR wszBuf[MAX_LOG_LENGTH] = {0};
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf));
|
||||
OutputDebugStringW(wszBuf);
|
||||
OutputDebugStringA("\n");
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), buf, sizeof(buf), NULL, FALSE);
|
||||
printf("%s\n", buf);
|
||||
printf("%s", buf);
|
||||
|
||||
#else
|
||||
// Linux, Mac, iOS, etc
|
||||
|
@ -516,7 +514,7 @@ void Console::loop()
|
|||
timeout.tv_sec = 0;
|
||||
|
||||
/* 0.016 seconds. Wake up once per frame at 60PFS */
|
||||
timeout.tv_usec = 016000;
|
||||
timeout.tv_usec = 16000;
|
||||
|
||||
while(!_endThread) {
|
||||
|
||||
|
|
|
@ -324,7 +324,8 @@ void Layout::onBeforeVisitScissor()
|
|||
{
|
||||
Rect clippingRect = getClippingRect();
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
EGLView::getInstance()->setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height);
|
||||
auto glview = Director::getInstance()->getOpenGLView();
|
||||
glview->setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height);
|
||||
}
|
||||
|
||||
void Layout::onAfterVisitScissor()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9e0b19c08146ef6fa0a23d57517a13b4404f03bd
|
||||
Subproject commit 39c992286292b7cb04fc6c8c55a9b117e92b7472
|
|
@ -631,7 +631,7 @@ color3B = Color3B::WHITE;
|
|||
| Director::sharedDirector() | Director::getInstance() |
|
||||
| FileUtils::sharedFileUtils | FileUtils::getInstance |
|
||||
| FileUtils::purgeFileUtils | FileUtils::destroyInstance |
|
||||
| EGLView::sharedOpenGLView | EGLView::getInstance |
|
||||
| GLView::sharedOpenGLView | GLView::getInstance |
|
||||
| ShaderCache::sharedShaderCache | ShaderCache::getInstance |
|
||||
| ShaderCache::purgeSharedShaderCache | ShaderCache::destroyInstance |
|
||||
| AnimationCache::sharedAnimationCache | AnimationCache::getInstance |
|
||||
|
|
|
@ -29,15 +29,18 @@
|
|||
#define kLabelZOrder 9999
|
||||
|
||||
#include "CCEditBox.h"
|
||||
#import "EAGLView.h"
|
||||
#import "CCEAGLView.h"
|
||||
|
||||
#define getEditBoxImplIOS() ((cocos2d::extension::EditBoxImplIOS*)editBox_)
|
||||
|
||||
static const int CC_EDIT_BOX_PADDING = 5;
|
||||
|
||||
@implementation CCCustomUITextField
|
||||
- (CGRect)textRectForBounds:(CGRect)bounds {
|
||||
float padding = CC_EDIT_BOX_PADDING * cocos2d::EGLView::getInstance()->getScaleX() / [[CCEAGLView sharedEGLView] contentScaleFactor ];
|
||||
- (CGRect)textRectForBounds:(CGRect)bounds
|
||||
{
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
|
||||
float padding = CC_EDIT_BOX_PADDING * glview->getScaleX() / glview->getContentScaleFactor();
|
||||
return CGRectMake(bounds.origin.x + padding, bounds.origin.y + padding,
|
||||
bounds.size.width - padding*2, bounds.size.height - padding*2);
|
||||
}
|
||||
|
@ -92,8 +95,10 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
|||
|
||||
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance
|
||||
{
|
||||
id eglView = [CCEAGLView sharedEGLView];
|
||||
[eglView doAnimationWhenKeyboardMoveWithDuration:duration distance:distance];
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *) view->getEAGLView();
|
||||
|
||||
[eaglview doAnimationWhenKeyboardMoveWithDuration:duration distance:distance];
|
||||
}
|
||||
|
||||
-(void) setPosition:(CGPoint) pos
|
||||
|
@ -117,7 +122,10 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
|||
|
||||
-(void) openKeyboard
|
||||
{
|
||||
[[CCEAGLView sharedEGLView] addSubview:textField_];
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *) view->getEAGLView();
|
||||
|
||||
[eaglview addSubview:textField_];
|
||||
[textField_ becomeFirstResponder];
|
||||
}
|
||||
|
||||
|
@ -137,16 +145,21 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
|||
|
||||
-(void)animationSelector
|
||||
{
|
||||
id eglView = [CCEAGLView sharedEGLView];
|
||||
[eglView doAnimationWhenAnotherEditBeClicked];
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *) view->getEAGLView();
|
||||
|
||||
[eaglview doAnimationWhenAnotherEditBeClicked];
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldBeginEditing:(UITextField *)sender // return NO to disallow editing.
|
||||
{
|
||||
CCLOG("textFieldShouldBeginEditing...");
|
||||
editState_ = YES;
|
||||
id eglView = [CCEAGLView sharedEGLView];
|
||||
if ([eglView isKeyboardShown])
|
||||
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *) view->getEAGLView();
|
||||
|
||||
if ([eaglview isKeyboardShown])
|
||||
{
|
||||
[self performSelector:@selector(animationSelector) withObject:nil afterDelay:0.0f];
|
||||
}
|
||||
|
@ -261,7 +274,9 @@ EditBoxImplIOS::EditBoxImplIOS(EditBox* pEditText)
|
|||
, _systemControl(NULL)
|
||||
, _maxTextLength(-1)
|
||||
{
|
||||
_inRetinaMode = [[CCEAGLView sharedEGLView] contentScaleFactor] == 2.0f ? true : false;
|
||||
auto view = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
|
||||
_inRetinaMode = view->isRetinaDisplay();
|
||||
}
|
||||
|
||||
EditBoxImplIOS::~EditBoxImplIOS()
|
||||
|
@ -281,9 +296,9 @@ bool EditBoxImplIOS::initWithSize(const Size& size)
|
|||
{
|
||||
do
|
||||
{
|
||||
EGLViewProtocol* eglView = EGLView::getInstance();
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
|
||||
CGRect rect = CGRectMake(0, 0, size.width * eglView->getScaleX(),size.height * eglView->getScaleY());
|
||||
CGRect rect = CGRectMake(0, 0, size.width * glview->getScaleX(),size.height * glview->getScaleY());
|
||||
|
||||
if (_inRetinaMode)
|
||||
{
|
||||
|
@ -360,7 +375,10 @@ void EditBoxImplIOS::setFont(const char* pFontName, int fontSize)
|
|||
|
||||
float retinaFactor = _inRetinaMode ? 2.0f : 1.0f;
|
||||
NSString * fntName = [NSString stringWithUTF8String:pFontName];
|
||||
float scaleFactor = EGLView::getInstance()->getScaleX();
|
||||
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
|
||||
float scaleFactor = glview->getScaleX();
|
||||
UIFont *textFont = nil;
|
||||
if (isValidFontName) {
|
||||
textFont = [UIFont fontWithName:fntName size:fontSize * scaleFactor / retinaFactor];
|
||||
|
@ -536,11 +554,13 @@ void EditBoxImplIOS::setPlaceHolder(const char* pText)
|
|||
|
||||
static CGPoint convertDesignCoordToScreenCoord(const Point& designCoord, bool bInRetinaMode)
|
||||
{
|
||||
EGLViewProtocol* eglView = EGLView::getInstance();
|
||||
float viewH = (float)[[CCEAGLView sharedEGLView] getHeight];
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CCEAGLView *eaglview = (CCEAGLView *) glview->getEAGLView();
|
||||
|
||||
Point visiblePos = Point(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY());
|
||||
Point screenGLPos = visiblePos + eglView->getViewPortRect().origin;
|
||||
float viewH = (float)[eaglview getHeight];
|
||||
|
||||
Point visiblePos = Point(designCoord.x * glview->getScaleX(), designCoord.y * glview->getScaleY());
|
||||
Point screenGLPos = visiblePos + glview->getViewPortRect().origin;
|
||||
|
||||
CGPoint screenPos = CGPointMake(screenGLPos.x, viewH - screenGLPos.y);
|
||||
|
||||
|
@ -569,8 +589,8 @@ void EditBoxImplIOS::setContentSize(const Size& size)
|
|||
_contentSize = size;
|
||||
CCLOG("[Edit text] content size = (%f, %f)", size.width, size.height);
|
||||
placeInactiveLabels();
|
||||
EGLViewProtocol* eglView = EGLView::getInstance();
|
||||
CGSize controlSize = CGSizeMake(size.width * eglView->getScaleX(),size.height * eglView->getScaleY());
|
||||
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
|
||||
CGSize controlSize = CGSizeMake(size.width * glview->getScaleX(),size.height * glview->getScaleY());
|
||||
|
||||
if (_inRetinaMode)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue