关于 Cocos2d-x 3.2+Cocos studio截屏功能BUG,求大牛解决,+急!!

开发环境:
Cocos2d-x 3.2
Cocos studio (UI)

具体问题:

C++代码:
void JHCommon::saveScreenshot()
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCRenderTexture* texture = CCRenderTexture::create((int)size.width, (int)size.height);
texture->setPosition(ccp(size.width/2, size.height/2));
texture->begin();
CCDirector::sharedDirector()->getRunningScene()->visit();
texture->end();
texture->saveToFile(“screenshot.png”, kCCImageFormatPNG);
}

调用以上代码进行截屏,截屏后出现以下情况,如果不使用Cocos studio 堆UI则不会出现这种问题。 求大牛解决。。。

这是真机上的结果 还是 PC上的结果?

楼主创建renderTexture的时候记得用

RenderTexture * RenderTexture::create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat)

然后,指定最后一个参数为:
GL_DEPTH24_STENCIL8

如果是真机,记得开启stencil buffer。ios默认是开启的,android的话可以参考 http://www.cocoachina.com/bbs/read.php?tid=196847

第3个参数可以是Texture2D::PixelFormat::AUTO

PC、真机都是这样。

好,我去试下。 等下在回复您!

参数3:不能使用AUTO会被断掉。
我换成了RGBA8888,不知道会不会在真机上有影响。
RenderTexture* texture = RenderTexture::create((int)size.width, (int)size.height, Texture2D::PixelFormat::RGBA8888 , GL_DEPTH24_STENCIL8);

哦,那就用RGBA8888吧,真机你可以测试一下,应该不会有问题。

真机也试过了,没问题了。 谢谢你偶像。
看着你教程入的门!! 跟你在网上说话有些激动。。

:14: 搞定了就好,哈哈

终于找到了 谢谢 论坛各位大神

看了这帖子之后,我忙活了一天的问题终于有了答案,兴奋之余,顺便表达一下对各位的感谢 “TMTNBL”

— Begin quote from ____

引用第2楼子龙山人于2014-08-11 16:41发表的 回 楼主(weizeteng) 的帖子 :

楼主创建renderTexture的时候记得用

RenderTexture * RenderTexture::create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat)

http://www.cocoachina.com/bbs/job.php?action=topost&tid=220090&pid=1026745

— End quote

遇到同样的问题 , 使用这个方法解决 问题了 . 谢谢