Cocos2D CCRenderTexture莫名其妙报错的问题

注意两点就行了:

一个就是:

1。CCRenderTexture在初始化的时候高度和宽度不能小于1(这是模拟器的要求)

报错之后的表现为:

虽然画面卡住(就如同opengles罢工不做渲染了一样),但程序依然能够正常执行,box2d引擎工作也很正常(通过控制台输出进行检查)~

满足了上述的要求,程序能够很好的运行在模拟器里面~

但是,在模拟器里面能很好的运行不代表也能在设备里面很好的运行~

就如同之前的音频播放一样,在模拟器和真机上这两者是有区别的,那就是:

2。CCRenderTexture的高度和宽度在设备里面一定不能小于 32(详见如下提供的资料)

3。CCRenderTexture的高度和宽度不能大于 1024 (Added By BruceYang on 2012.01.10.15.23)~

报错之后的表现为:

这会程序算是真正的死掉了(因为我没划过屏幕一下就会播放一段声音,在模拟器里面画面卡住声音还在,真机里面声音也不在了)~

资料转载自:http://code.google.com/p/cocos2d-iphone/issues/detail?id=1187

Issue 1187: Error initializing RenderTexture with specific sizes
2 people starred this issue and may be notified of changes.

Reported by  boidin.c...@gmail.comMay 24, 2011
What steps will reproduce the problem?
Create a RenderTexture with size 8-32 : 
CCRenderTexture *t = [CCRenderTexture renderTextureWithWidth:8 height:32];    

What is the expected output? What do you see instead?
It should work but it gives the following error on the iPad device :
 *** Terminating app due to uncaught exception 'Render Texture', reason: 'Could not attach texture to framebuffer'

What cocos2d version are you using ?
v1.0.0-rc2

What iOS / Mac SDK are you using ?
iOS 4.2.1 and 4.3.3

Debug or Release ?
debug and release

Which target device / target OS are you using ?
iPad iOS 4.2.1 and 4.3.3

iOS only: Does this happens on device ? or on the simulator ? or on both ?
Only on the device.

Please provide any additional information below.
The same error happens with other sizes, like 2 - 8.
When catching the error, the openGL state is not correct. Adding the following line before raising the exception would allow to continue running the application :
ccglBindFramebuffer(CC_GL_FRAMEBUFFER, oldFBO_);


Comment 1 by project member marcotil...@gmail.comMay 27, 2011
The minimum size of a render texture is 32 pixels, the minimum size for a FBO. It's a apple limitation/bug. More information about this can be found on the apple dev forums. 

If you want the application to continue, you could change the NSException into a NSAssert. Adding that line would make the check obsolete, since it binds the frame buffer of the screen and not the just created one of the render texture. The screen FBO will be tested that way instead of the one from the render texture. 

I've changed the status to wontfix, since this isn't a cocos bug. If you think I'm mistaken or have a work-around / solution for this, the issue can always be reopened. 
Status: WontFix

接下来探讨一下学习的方法论:

从上述资料中可以得到一些收获,cocos2d是由社区维护的,有上面这份详细的资料表明:

今后遇到了问题的话,随时可以报告给cocos2d官方,让这些专业的人员来为我提供帮助!

所以,这个网站要牢牢的记住,今后有什么自己不能独立解决的bug出现了,这里是一个帮助解决bug很好的助力

次之,很佩服cocos2d社区,这份资料体现了出了很好的bug处理机制,已经不逊于java的抛异常机制了

Satus:WontFix:哈哈,刚开始还没看懂,根据读音来猜应该是cocos2d的开发成员想说:

这个并不是cocos2d的bug,而是苹果自身的限制,而且报错机理和解决方案我已经给出来了,

就按我说的做吧,这个算不上bug的bug我们是不会去“修复”的~

最后,要提一提遇到bug时候的心态,虽然我已经被几个大bug搞得身心俱疲,以斗士的心态来面对bug

这是我所提倡的,虽然我自己都做不到,但是我还是会尽力让自己朝着这方面去努力!

真机测试报错的bug就是上面那一句:

Terminating app due to uncaught exception 'Render Texture', reason: 'Could not attach texture to framebuffer'
然后就没了,错误是出在哪儿的都不知道

(之前错误处在哪儿不知道是因为我对XCode不熟,后来发现有时候在线程那一栏还是会提示错误的发生点的,

但是这次,是真不知道了,线程那一栏里面显示在appDelegate,也就是差不多是程序的第一行代码的里面报错了,

天知道问题出在哪儿?)

但是有时候bug他就是纸老虎,要做的也仅仅是将上面那句最最关键的报错提示粘贴到google的搜索栏里面

然后,要么bug解决,要么。。。。。

能不能将问题解决掉我不敢打包票,但从这次实践的效果上来看,似乎不错~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值