i test it in cocos2d-x 3.11 demo apk , the problem still exist. i copy my apk to the android device and setup , when completed the system show two button(“complete” and “open”)
1.if i open it by the “open” button , apk running and i press HOME come to foreground and background , it must be reload all texture because opengl context lost.
2.if i didn’t press “open” button just open from destop , it nerver reload all texture , everytimes change background to foreground just fine. no texture to reload and display so fine
i find difference in javaactivity-android.cpp , the 1 situation ,always coming when change background to foreground and reload all texture the 2 situation it never come here
but i don’t know why and how to fix
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);
cocos2d::Application::getInstance()->run();
}
else
{
// when i open by the "open" button the system give, it must come into there
cocos2d::GL::invalidateStateCache();
cocos2d::GLProgramCache::getInstance()->reloadDefaultGLPrograms();
cocos2d::DrawPrimitives::init();
cocos2d::VolatileTextureMgr::reloadAllTextures();
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
director->setGLDefaultValues();
}
cocos2d::network::_preloadJavaDownloaderClass();
}