2011-03-01 19:53:39 +08:00
|
|
|
#include "AppDelegate.h"
|
2011-02-25 13:35:27 +08:00
|
|
|
#include "cocos2d.h"
|
2012-02-09 15:49:14 +08:00
|
|
|
#include "platform/android/jni/JniHelper.h"
|
2010-12-06 09:51:21 +08:00
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
2011-02-25 13:35:27 +08:00
|
|
|
#define LOG_TAG "main"
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
2010-12-06 09:51:21 +08:00
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2012-02-09 15:49:14 +08:00
|
|
|
|
|
|
|
jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|
|
|
{
|
2012-02-09 16:27:15 +08:00
|
|
|
JniHelper::setJavaVM(vm);
|
2012-02-09 15:49:14 +08:00
|
|
|
|
2012-02-09 16:27:15 +08:00
|
|
|
return JNI_VERSION_1_4;
|
2012-02-09 15:49:14 +08:00
|
|
|
}
|
2010-12-06 09:51:21 +08:00
|
|
|
|
|
|
|
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
|
|
|
{
|
2011-01-10 17:54:44 +08:00
|
|
|
if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
|
|
|
|
{
|
2012-02-09 16:27:15 +08:00
|
|
|
cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
|
2011-04-24 22:52:21 +08:00
|
|
|
view->setFrameWidthAndHeight(w, h);
|
2011-02-26 15:52:57 +08:00
|
|
|
// if you want to run in WVGA with HVGA resource, set it
|
2011-06-25 12:11:40 +08:00
|
|
|
// view->create(480, 320);
|
2011-01-10 17:54:44 +08:00
|
|
|
cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);
|
2011-02-25 13:35:27 +08:00
|
|
|
|
2011-03-01 19:53:39 +08:00
|
|
|
AppDelegate *pAppDelegate = new AppDelegate();
|
2011-03-08 13:49:58 +08:00
|
|
|
cocos2d::CCApplication::sharedApplication().run();
|
2011-01-10 17:54:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-17 17:55:26 +08:00
|
|
|
ccDrawInit();
|
|
|
|
ccGLInvalidateStateCache();
|
|
|
|
cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
|
|
|
|
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
2011-04-06 16:29:58 +08:00
|
|
|
cocos2d::CCTextureCache::reloadAllTextures();
|
2011-01-10 17:54:44 +08:00
|
|
|
}
|
2010-12-06 09:51:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|