注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

没有你的天堂

Cobra'Nails' Blog.

 
 
 

日志

 
 

[z]cocos2d pvrtc  

2011-06-09 23:56:59|  分类: 他山之石 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

From cocos2d v0.7 onwards you can use non-raw PVRTC (PVR Texture compression) images. (Raw PVRTC images are supported since v0.5.2)

In order to load a non-raw PVRTC image you can use the same API that you were using to load PNG/BMP/JPEG images. eg:

// Sprite using PVRTC fileSprite *img = [Sprite spriteWithFile:@"test_image.pvr"];  // Texture Atlas with PVRTC fileTextureAtlas *textureAtlas = [TextureAtlas textureAtlasWithFile: @"atlastest.pvr" capacity:3];  // TileMapAtlas with PVR fileTileMapAtlas *tilemap = [TileMapAtlas tileMapAtlasWithTileFile:@"tiles.pvr" mapFile:@"levelmap.tga" tileWidth:16 tileHeight:16];// LabelAtlas with PVR fileLabelAtlas *label = [LabelAtlas labelAtlasWithString:@"123 Test" charMapFile:@"tuffy_bold_italic-charmap.pvr" itemWidth:48 itemHeight:64 startCharMap:' '];  

As you can see, the PVRTC support is transparent .
Using PVRTC files has the following benefits:

  • It reduces the loading time (less footprint)
  • It is faster, for it consumes less bandwidth
  • It is also faster, since it implies less texture switches because more textures can be in memory at the same time (I might be wrong on this one :)

To convert a PNG file to PVRTC use this step:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC -f PVR --channel-weighting-linear --bits-per-pixel-4 -o test_image.pvr test_image.png

Edit: Fixed grammar errors

  评论这张
 
阅读(174)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017