2012-04-19 14:35:52 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "platform/android/jni/JniHelper.h"
|
2012-04-26 17:36:32 +08:00
|
|
|
#include "CCEventType.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#include "HelloWorldScene.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)
|
|
|
|
{
|
|
|
|
if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
|
|
|
|
{
|
2012-04-23 14:30:38 +08:00
|
|
|
cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
|
|
|
|
view->setFrameSize(w, h);
|
2012-04-19 14:35:52 +08:00
|
|
|
// if you want to run in WVGA with HVGA resource, set it
|
2012-04-23 14:30:38 +08:00
|
|
|
// view->setDesignResolutionSize(480, 320); Please change it to (320, 480) if you're in portrait mode.
|
2012-04-19 14:35:52 +08:00
|
|
|
cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);
|
|
|
|
|
|
|
|
AppDelegate *pAppDelegate = new AppDelegate();
|
|
|
|
cocos2d::CCApplication::sharedApplication().run();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ccDrawInit();
|
|
|
|
ccGLInvalidateStateCache();
|
2012-04-24 15:02:18 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
|
|
|
cocos2d::CCTextureCache::reloadAllTextures();
|
2012-04-24 15:02:18 +08:00
|
|
|
cocos2d::CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
|
|
|
cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|