2012-04-19 14:35:52 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "cocos2d.h"
|
2012-04-24 15:02:18 +08:00
|
|
|
#include "CCEventType.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "platform/android/jni/JniHelper.h"
|
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#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)
|
|
|
|
{
|
2013-07-12 11:50:36 +08:00
|
|
|
if (!Director::getInstance()->getOpenGLView())
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-12 13:11:21 +08:00
|
|
|
EGLView *view = EGLView::getInstance();
|
2012-08-15 14:33:56 +08:00
|
|
|
view->setFrameSize(w, h);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
AppDelegate *pAppDelegate = new AppDelegate();
|
2013-07-15 16:24:42 +08:00
|
|
|
Application::getInstance()->run();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ccGLInvalidateStateCache();
|
2013-07-12 13:40:01 +08:00
|
|
|
ShaderCache::getInstance()->reloadDefaultShaders();
|
2013-07-17 12:53:30 +08:00
|
|
|
ccDrawInit();
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::reloadAllTextures();
|
2013-07-12 14:17:42 +08:00
|
|
|
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
2013-07-12 11:50:36 +08:00
|
|
|
Director::getInstance()->setGLDefaultValues();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|