原帖链接:
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.
( )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:
# CC_TEXTURE_NPOT_SUPPORT 1
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 withfile
: $ find . -name "*.png" -print0 | xargs -0 file
B) Run this line of code and see your debug console:
[[CCTextureCache sharedTextureCache] dumpCachedTextureInfo];
Further info:
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