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)
|
|
|
|
{
|
2012-05-02 12:04:27 +08:00
|
|
|
if (!CCDirector::sharedDirector()->getOpenGLView())
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-05-02 12:04:27 +08:00
|
|
|
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
2012-04-23 14:30:38 +08:00
|
|
|
view->setFrameSize(w, h);
|
2012-05-02 17:50:26 +08:00
|
|
|
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
2012-05-31 10:13:05 +08:00
|
|
|
// view->setDesignResolutionSize(480, 320);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
AppDelegate *pAppDelegate = new AppDelegate();
|
2012-05-02 12:04:27 +08:00
|
|
|
CCApplication::sharedApplication().run();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ccDrawInit();
|
|
|
|
ccGLInvalidateStateCache();
|
2012-04-24 15:02:18 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
2012-05-02 12:04:27 +08:00
|
|
|
CCTextureCache::reloadAllTextures();
|
|
|
|
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
|
|
|
CCDirector::sharedDirector()->setGLDefaultValues();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|