axmol/tests/proj.android/jni/tests/main.cpp

46 lines
1.3 KiB
C++
Raw Normal View History

#include "AppDelegate.h"
#include "cocos2d.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)
{
2012-02-09 16:27:15 +08:00
JniHelper::setJavaVM(vm);
2012-02-09 16:27:15 +08:00
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-02-09 16:27:15 +08:00
cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
view->setFrameWidthAndHeight(w, h);
// if you want to run in WVGA with HVGA resource, set it
// view->create(480, 320);
cocos2d::CCDirector::sharedDirector()->setOpenGLView(view);
AppDelegate *pAppDelegate = new AppDelegate();
2011-03-08 13:49:58 +08:00
cocos2d::CCApplication::sharedApplication().run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
cocos2d::CCDirector::sharedDirector()->setGLDefaultValues();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
cocos2d::CCTextureCache::reloadAllTextures();
}
}
}