2013-02-19 15:38:30 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "CCEventType.h"
|
|
|
|
#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())
|
2013-02-19 15:38:30 +08:00
|
|
|
{
|
2013-07-12 13:11:21 +08:00
|
|
|
EGLView *view = EGLView::getInstance();
|
2013-02-19 15:38:30 +08:00
|
|
|
view->setFrameSize(w, h);
|
|
|
|
|
|
|
|
AppDelegate *pAppDelegate = new AppDelegate();
|
2013-07-15 16:24:42 +08:00
|
|
|
Application::getInstance()->run();
|
2013-02-19 15:38:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-26 14:00:10 +08:00
|
|
|
GL::invalidateStateCache();
|
2013-07-12 13:40:01 +08:00
|
|
|
ShaderCache::getInstance()->reloadDefaultShaders();
|
2013-07-25 22:38:55 +08:00
|
|
|
DrawPrimitives::init();
|
2013-06-20 22:18:43 +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();
|
2013-02-19 15:38:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|