workaround for %33 texture memory bug
原帖鏈接:http://www.cocos2d-iphone.org/forum/topic/29121
PS:
為什么要關心 NPOT 呢?
因為蘋果的OpenGL驅動有一個bug,導致如果使用 POT 的紋理,則會產生額外33%的內存消耗。
So,
If you didn't know, when you create a texture, iOS will allocate 33% more memory, presumably to have enough room in case mipmaps are needed.
(?http://www.cocos2d-iphone.org/forum/topic/23887#post-129097?)
But it is worth noting that this bug is only present on POT (Power Of Two) textures ( Mipmapping is only supported on POT textures ).
So, in order to reduce memory, what you have to do is two create NPOT textures.
eg:
If you are using a 2048x2048 textures, convert it into a 2048x2047 textures (and you will save 33% memory).
In case you can't make it smaller, then make it bigger. eg:
If you have a 2048x1024 texture, create a 2048x1025 texture.
If you are using cocos2d v1.0, then you have to edit?ccConfig.h?with:
If you are using v1.1 or v2.0, then you are OK, since they already support NPOT textures by default.
Ways to know if you are using POT / NPOT textures:
A)?Parse your PNG, GIF, BMP, JPEG files with?file:
B)?Run this line of code and see your debug console:
Further info:
https://devforums.apple.com/thread/113889?start=0&tstart=0
Important: NPOT textures can't have mipmaps, and also they only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}
Important 2: PVRTC (2bpp and 4bpp) textures can't be converted to NPOT
轉載于:https://www.cnblogs.com/java20130723/archive/2013/01/26/3212056.html
總結
以上是生活随笔為你收集整理的workaround for %33 texture memory bug的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS使用NSURLConnection
- 下一篇: POJ-3635 Full Tank?