CCClippingNode导致的贴图错误问题

前端之家收集整理的这篇文章主要介绍了CCClippingNode导致的贴图错误问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

此问题我的原文和解决办法:

http://stackoverflow.com/questions/28367881/why-i-need-add-empty-ccclippingnode-between-each-slice-part-in-cocos2dx-2-2-6/28367882#28367882

帮助贴:

http://blog.csdn.net/jusnxie/article/details/9277121


起先我发现切割图片的贴图错误了,但是找不到问题在哪. 于是我自己来回测试,发现每隔一个CCClippingNode创建一个空的CCClippingNode就不会出现这个问题,于是我发现了是openGL缓存的问题,




另外stencil深度需要开启,cpp项目在AppController.mm中,默认新版模板是开启的,老版模板是关闭的,所以我发现我的demo能运行,而老游戏不支持:


改为


EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
                                     pixelFormat: kEAGLColorFormatRGB565
                                     depthFormat: GL_DEPTH24_STENCIL8_OES
                              preserveBackbuffer: NO
                                      sharegroup: nil
                                   multiSampling: NO
                                 numberOfSamples:0 ];





  1. glStencilFunc(GL_NEVER,mask_layer,mask_layer);
  2. glClearStencil(!m_bInverted?0:~0);
  3. glStencilOp(!m_bInverted?GL_ZERO:GL_REPLACE,GL_KEEP,GL_KEEP);
  4. //drawafullscreensolidrectangletoclearthestencilbuffer
  5. //ccDrawSolidRect(CCPointZero,ccpFromSize([[CCDirectorsharedDirector]winSize]),ccc4f(1,1,1));
  6. ccDrawSolidRect(CCPointZero,ccpFromSize(CCDirector::sharedDirector()->getWinSize()),1));
  7. glClear(GL_STENCIL_BUFFER_BIT);

标红的地方是新添加的,效果刚刚

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

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