I have a simple project where I draw some lines and some labels (using CCLabelBMFont). They’re simply children of the CCLayer.
Everything draws fine when I change activity and come back, everything draws fine when I press the home button and launch the application again. But when I use the back button to go out of the application and I launch it again all my labels become black rectangles.
The only thing I did was uncomment the code in Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit in main.cpp, when this code is commented the activity will never be redrawn and I get a black screen.
if (!CCDirector::sharedDirector()->getOpenGLView())
{
CCEGLView *view = CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
}
Only when the back button was used to go out of the application and the application is opened again will we enter the else clause of above code. So I hope somebody has an idea why labels aren’t displayed properly in this situation.
Edit: My problem is related to this topic: http://cocos2d-x.org/boards/6/topics/27903. I also get the draw 589 error, so the issue is reloading the textures. I will follow that topic in the hope of getting a solution.