CCClippingNode的一个bug

原文地址:http://www.cnblogs.com/icethawless/archive/2013/05/16/3082004.html

ocos2d-x v2.1.3 模板缓冲区的清空有问题,当应用了模板测试的节点移动或者缩放时,就能看出来,有明显的拖影,裁剪区域和预设的不一致。

网上搜了一下,看到cocos2d-iphone版本已经给出了解决方案,需要改一下CCClippingNode.cpp,可能是cocos2dx这边还没有同步吧:

https://github.com/cocos2d/cocos2d-iphone/commit/b02c8a8686620cfc932b90c8e1ff78d9fcbe205a

修改后代码:
///
    // CLEAR STENCIL BUFFER
    
    // manually clear the stencil buffer by drawing a fullscreen rectangle on it
    // setup the stencil test func like this:
    // for each pixel in the fullscreen rectangle
    //     never draw it into the frame buffer
    //     if not in inverted mode: set the current layer value to 0 in the stencil buffer
    //     if in inverted mode: set the current layer value to 1 in the stencil buffer
    glStencilFunc(GL_NEVER, mask_layer, mask_layer);
    glClearStencil(!m_bInverted ? 0 : ~0);
    glStencilOp(!m_bInverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
    
    // draw a fullscreen solid rectangle to clear the stencil buffer
    //ccDrawSolidRect(CCPointZero, ccpFromSize([[CCDirector sharedDirector] winSize]), ccc4f(1, 1, 1, 1));
    ccDrawSolidRect(CCPointZero, ccpFromSize(CCDirector::sharedDirector()->getWinSize()), ccc4f(1, 1, 1, 1));
    glClear(GL_STENCIL_BUFFER_BIT);


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值