From f55aedb5e98f24a622be85112bd30d8a2ec526d1 Mon Sep 17 00:00:00 2001 From: mustime Date: Fri, 24 Aug 2012 10:18:59 +0800 Subject: [PATCH] issue #1425: add android proj on TestLua --- samples/TestLua/proj.android/jni/Android.mk | 35 +++++++++++++++ .../TestLua/proj.android/jni/Application.mk | 3 ++ .../TestLua/proj.android/jni/testlua/main.cpp | 45 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 samples/TestLua/proj.android/jni/Android.mk create mode 100644 samples/TestLua/proj.android/jni/Application.mk create mode 100644 samples/TestLua/proj.android/jni/testlua/main.cpp diff --git a/samples/TestLua/proj.android/jni/Android.mk b/samples/TestLua/proj.android/jni/Android.mk new file mode 100644 index 0000000000..ced3a1c4dc --- /dev/null +++ b/samples/TestLua/proj.android/jni/Android.mk @@ -0,0 +1,35 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := testlua_shared + +LOCAL_MODULE_FILENAME := libtestlua + +LOCAL_SRC_FILES := testlua/main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../../../scripting/lua/cocos2dx_support/CCLuaEngine.cpp \ + ../../../../scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ + ../../../../scripting/lua/cocos2dx_support/LuaCocos2d.cpp \ + ../../../../scripting/lua/cocos2dx_support/tolua_fix.c + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + +LOCAL_STATIC_LIBRARIES := curl_static_prebuilt + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static +LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static +LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,cocos2dx) +$(call import-module,CocosDenshion/android) +$(call import-module,scripting/lua/proj.android/jni) +$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) +$(call import-module,extensions) +$(call import-module,external/Box2D) +$(call import-module,external/chipmunk) \ No newline at end of file diff --git a/samples/TestLua/proj.android/jni/Application.mk b/samples/TestLua/proj.android/jni/Application.mk new file mode 100644 index 0000000000..f5e25d70ef --- /dev/null +++ b/samples/TestLua/proj.android/jni/Application.mk @@ -0,0 +1,3 @@ +APP_STL := gnustl_static +APP_CPPFLAGS := -frtti +APP_CPPFLAGS += -fexceptions diff --git a/samples/TestLua/proj.android/jni/testlua/main.cpp b/samples/TestLua/proj.android/jni/testlua/main.cpp new file mode 100644 index 0000000000..50e7abdf30 --- /dev/null +++ b/samples/TestLua/proj.android/jni/testlua/main.cpp @@ -0,0 +1,45 @@ +#include "AppDelegate.h" +#include "cocos2d.h" +#include "CCEventType.h" +#include "platform/android/jni/JniHelper.h" +#include +#include + +#define LOG_TAG "main" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +using namespace cocos2d; + +extern "C" +{ + +jint JNI_OnLoad(JavaVM *vm, void *reserved) +{ + JniHelper::setJavaVM(vm); + + return JNI_VERSION_1_4; +} + +void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) +{ + if (!CCDirector::sharedDirector()->getOpenGLView()) + { + CCEGLView *view = CCEGLView::sharedOpenGLView(); + view->setFrameSize(w, h); + + AppDelegate *pAppDelegate = new AppDelegate(); + CCApplication::sharedApplication()->run(); + } + else + { + ccDrawInit(); + ccGLInvalidateStateCache(); + + CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); + CCTextureCache::reloadAllTextures(); + CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); + CCDirector::sharedDirector()->setGLDefaultValues(); + } +} + +}