cocos2dx 3.12 iOS build assert error cocos2d-x C++

前端之家收集整理的这篇文章主要介绍了cocos2dx 3.12 iOS build assert error cocos2d-x C++前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

I'm having a problem when trying to build for iOS. It compiles/build without errors,but when it's trying to run the game throws this assert error:

Assert Failed: Unsupported format for depth and stencil buffers. Using default
Assertion Failed: (0),function convertAttrs,file /Users/spacolino/development/games/boringame/cocos2d/cocos/platform/ios/CCGLViewImpl-ios.mm,line 107.

In source it looks like this:

if(_glContextAttrs.depthBits==24 && _glContextAttrs.stencilBits==8)
{
    _depthFormat = GL_DEPTH24_STENCIL8_OES;
} else if (_glContextAttrs.depthBits==0 && _glContextAttrs.stencilBits==0)
{
    _depthFormat = 0;
} else
{
    CCASSERT(0,"Unsupported format for depth and stencil buffers. Using default");
}

}

Do I have to set some depth format or stencil buffer? Or?
I've tried it on simulator and iphone 5s. It gives the same error.
If you need any additional info please tell me.

Thank you!

spacolino

Found the problem. I had to add in AppDelegate:

void AppDelegate::initGLContextAttrs()
{
    // set OpenGL context attributes: red,green,blue,alpha,depth,stencil
    GLContextAttrs glContextAttrs = {8,8,24,8};

    GLView::setGLContextAttrs(glContextAttrs);
}

I was porting my game from an older 3.4 version to 3.12. If you compare test examples or generated projects of an older Cocos2dx 3.4 version with 3.12 you'll see the difference. Hope it helps to someone.

原文链接:https://www.f2er.com/cocos2dx/339227.html

猜你在找的Cocos2d-x相关文章