cocos2d-x 3.5, 调用Director::getInstance()->end()后再进入报错restoreRenderState 170。急急急!!!

  • (void)startView
    {
    if (sManManViewController)
    {
    CCLOG(“ManManViewController had been created!”);
    return;
    }

    //主window
    UIWindow* window = [UIApplication sharedApplication].delegate.window;

    cocos2d::Application *app = cocos2d::Application::getInstance();
    app->initGLContextAttrs();
    cocos2d::GLViewImpl::convertAttrs();

    // Add the view controller’s view to the window and display.
    //window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
    CCEAGLView eaglView = [CCEAGLView viewWithFrame: [window bounds]
    pixelFormat: (NSString
    )cocos2d::GLViewImpl::_pixelFormat
    depthFormat: cocos2d::GLViewImpl::_depthFormat
    preserveBackbuffer: NO
    sharegroup: nil
    multiSampling: NO
    numberOfSamples: 0 ];

    [eaglView setMultipleTouchEnabled:YES];

    // Use RootViewController manage CCEAGLView
    sManManViewController = [[ManManViewController alloc] initWithNibName:nil bundle:nil];
    sManManViewController.wantsFullScreenLayout = YES;
    sManManViewController.view = eaglView;

    FImagePicker::getInstance()->setViewController(sManManViewController);
    FEaseSdkManager::getInstance()->setViewController(sManManViewController);
    QrCodeScanning::getInstance()->setViewController(sManManViewController);

    // Set RootViewController to window
    // if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
    // {
    // // warning: addSubView doesn’t work on iOS6
    // [window addSubview: viewController.view];
    // }
    // else
    // {
    // // use this method on ios6
    // [window setRootViewController:viewController];
    // }

    [window addSubview: sManManViewController.view];

    // [window makeKeyAndVisible];

    [[UIApplication sharedApplication] setStatusBarHidden: YES];

    // IMPORTANT: Setting the GLView should be done after creating the RootViewController
    cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
    cocos2d::Director::getInstance()->setOpenGLView(glview);

    app->run();

    //创建ManManAppController
    sManManAppController = [[ManManAppController alloc] init];
    }

  • (void)endView
    {
    if (sManManViewController)
    {
    cocos2d::Director::getInstance()->end();
    cocos2d::Application::getInstance()->stop();

      [sManManViewController.view removeFromSuperview];
      [sManManViewController release];
      sManManViewController = nil;
      
      [sManManAppController release];
      sManManAppController = nil;
    

    }
    }

我调用startView进入cocos,然后再调用endView退出,接着在调用startView进入的话会报错CCRenderer.cpp restoreRenderState 170,有没有大牛给解决下问题?

没人回复?? 自己先来个,我是吧cocos的openGLView嵌入一个应用,然后这个应用可以进入和退出cocos,但是第二次进入的话就会报错CCRenderer.cpp restoreRenderState 170,有没有高手看看??用的cocos2d-x3.5的版本。版主在不??

我之前也遇到过此问题,你可以查看一下cocos2dx中是否有未释放的单利,比如http或者schedule什么的。第二点就是可以尝试通知模式在cocos2dx的类中调用end()方法

schedule都在cocos2d::Director::getInstance()->end(); 里面清除掉了,http不用处理吧? 感觉是不是openGL哪里没有清除状态?

使用最新版本的3.15.1,还是会有问题,重新退出和在进入cocos,3d绘制会报错,唉, 我感觉心好累啊!!!

OK,这个问题已经解决

怎么解决的,能分享一下嘛?