mirror of https://github.com/axmolengine/axmol.git
JNI, Set JavaVM
This commit is contained in:
parent
4539600ac2
commit
a2a999d505
|
@ -15,6 +15,7 @@
|
||||||
#include "CCEventType.h"
|
#include "CCEventType.h"
|
||||||
#include "support/CCNotificationCenter.h"
|
#include "support/CCNotificationCenter.h"
|
||||||
#include "CCFileUtilsAndroid.h"
|
#include "CCFileUtilsAndroid.h"
|
||||||
|
#include "jni/JniHelper.h"
|
||||||
|
|
||||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "cocos2dx/nativeactivity.cpp", __VA_ARGS__))
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "cocos2dx/nativeactivity.cpp", __VA_ARGS__))
|
||||||
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "cocos2dx/nativeactivity.cpp", __VA_ARGS__))
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "cocos2dx/nativeactivity.cpp", __VA_ARGS__))
|
||||||
|
@ -62,6 +63,14 @@ typedef struct cocos_dimensions {
|
||||||
int h;
|
int h;
|
||||||
} cocos_dimensions;
|
} cocos_dimensions;
|
||||||
|
|
||||||
|
static void jnihelper_init(JavaVM* vm) {
|
||||||
|
LOGI("jnihelper_init(...)");
|
||||||
|
pthread_t thisthread = pthread_self();
|
||||||
|
LOGI("pthread_self() = %X", thisthread);
|
||||||
|
|
||||||
|
cocos2d::JniHelper::setJavaVM(vm);
|
||||||
|
}
|
||||||
|
|
||||||
static void cocos_init(cocos_dimensions d, AAssetManager* assetmanager) {
|
static void cocos_init(cocos_dimensions d, AAssetManager* assetmanager) {
|
||||||
LOGI("cocos_init(...)");
|
LOGI("cocos_init(...)");
|
||||||
pthread_t thisthread = pthread_self();
|
pthread_t thisthread = pthread_self();
|
||||||
|
@ -243,6 +252,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
||||||
cocos_dimensions d = engine_init_display(engine);
|
cocos_dimensions d = engine_init_display(engine);
|
||||||
if ((d.w > 0) &&
|
if ((d.w > 0) &&
|
||||||
(d.h > 0)) {
|
(d.h > 0)) {
|
||||||
|
jnihelper_init(app->activity->vm);
|
||||||
cocos_init(d, app->activity->assetManager);
|
cocos_init(d, app->activity->assetManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue