mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
New renderer (#1097)
* build work on mac * build ok on iOS * fix compiling error on android * fix android link error
This commit is contained in:
@@ -26,16 +26,8 @@ THE SOFTWARE.
|
||||
#include "platform/CCPlatformConfig.h"
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
|
||||
#include "platform/android/CCApplication-android.h"
|
||||
#include "platform/android/CCGLViewImpl-android.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "renderer/CCGLProgramCache.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "2d/CCDrawingPrimitives.h"
|
||||
#include "platform/android/jni/JniHelper.h"
|
||||
#include "network/CCDownloader-android.h"
|
||||
#include <android/log.h>
|
||||
@@ -86,55 +78,55 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
auto director = cocos2d::Director::getInstance();
|
||||
auto glview = director->getOpenGLView();
|
||||
if (!glview)
|
||||
{
|
||||
glview = cocos2d::GLViewImpl::create("Android app");
|
||||
glview->setFrameSize(w, h);
|
||||
director->setOpenGLView(glview);
|
||||
// auto director = cocos2d::Director::getInstance();
|
||||
// auto glview = director->getOpenGLView();
|
||||
// if (!glview)
|
||||
// {
|
||||
// glview = cocos2d::GLViewImpl::create("Android app");
|
||||
// glview->setFrameSize(w, h);
|
||||
// director->setOpenGLView(glview);
|
||||
|
||||
cocos2d::Application::getInstance()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
cocos2d::GL::invalidateStateCache();
|
||||
cocos2d::GLProgramCache::getInstance()->reloadDefaultGLPrograms();
|
||||
cocos2d::DrawPrimitives::init();
|
||||
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
||||
// cocos2d::Application::getInstance()->run();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cocos2d::GL::invalidateStateCache();
|
||||
// cocos2d::GLProgramCache::getInstance()->reloadDefaultGLPrograms();
|
||||
// cocos2d::DrawPrimitives::init();
|
||||
// cocos2d::VolatileTextureMgr::reloadAllTextures();
|
||||
|
||||
cocos2d::EventCustom* recreatedEvent = new (std::nothrow) cocos2d::EventCustom(EVENT_RENDERER_RECREATED);
|
||||
director->getEventDispatcher()->dispatchEvent(recreatedEvent);
|
||||
recreatedEvent->release();
|
||||
// cocos2d::EventCustom* recreatedEvent = new (std::nothrow) cocos2d::EventCustom(EVENT_RENDERER_RECREATED);
|
||||
// director->getEventDispatcher()->dispatchEvent(recreatedEvent);
|
||||
// recreatedEvent->release();
|
||||
|
||||
director->setGLDefaultValues();
|
||||
}
|
||||
cocos2d::network::_preloadJavaDownloaderClass();
|
||||
// director->setGLDefaultValues();
|
||||
// }
|
||||
// cocos2d::network::_preloadJavaDownloaderClass();
|
||||
}
|
||||
|
||||
JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz)
|
||||
{
|
||||
cocos2d::Application::getInstance()->initGLContextAttrs();
|
||||
GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs();
|
||||
// cocos2d::Application::getInstance()->initGLContextAttrs();
|
||||
// GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs();
|
||||
|
||||
int tmp[6] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits,
|
||||
_glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits};
|
||||
// int tmp[6] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits,
|
||||
// _glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits};
|
||||
|
||||
|
||||
jintArray glContextAttrsJava = env->NewIntArray(6);
|
||||
env->SetIntArrayRegion(glContextAttrsJava, 0, 6, tmp);
|
||||
// jintArray glContextAttrsJava = env->NewIntArray(6);
|
||||
// env->SetIntArrayRegion(glContextAttrsJava, 0, 6, tmp);
|
||||
|
||||
return glContextAttrsJava;
|
||||
// return glContextAttrsJava;
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxAudioFocusManager_nativeOnAudioFocusChange(JNIEnv* env, jobject thiz, jint focusChange)
|
||||
{
|
||||
cocos_audioengine_focus_change(focusChange);
|
||||
// cocos_audioengine_focus_change(focusChange);
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
cocos2d::Application::getInstance()->applicationScreenSizeChanged(w, h);
|
||||
// cocos2d::Application::getInstance()->applicationScreenSizeChanged(w, h);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user