png to pvrtc move

Member
Posts: 306
Joined: 2009.03
Post: #1
So I am running low on memory so i started converting some of my static images to pvrtc. I did this using the command line tool. Looks ok. Problem is, imageWithContentsOfFile doesn't seem to be able to load one. Texture2D sample uses that so I assume they are trying to convert after the fact, or at runtime. But I would like to use my prerendered one for speed. Does anyone know how to get a pvrtc into a gl texture from a pvrtc file?

Looking at Texture2D a little more, it doesn't event support you passing in the enum values for pvrtc. If anyone has a sample with the dynamic converting, that would help too. Thanks.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2009.02
Post: #2
Hey Kendric,

The Texture2D class doesn't support pvrtc textures. However, there is a similar class called PVRTexture that does exactly what you are looking for. It can be found on the iPhone Dev Portal as part of the PVRTC Texture Example Code. In our apps, we use both Texture2D and the PVRTexture class, works like a charm.

-Keith
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #3
This is exactly what I wanted. However when I used it it doesnt seem to like my file. I created it using the following:
/texturetool -e PVRTC --channel-weighting-linea --bits-per-pixel-4 -o ~/test.pvrtc -p ~/test.png ~/front.png

The sample file that it output looks good so I believe the file was created correctly.
When the pvrtc is being created, it loads the data ok from the file but it seems to fail at this line.

if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) ||
gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) ||
gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) ||
gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff))
{
return FALSE;
}

If you have any suggestions let me know. The path I am passing to:
PVRTexture* texture=[[PVRTexture alloc] initWithContentsOfFile:actualFile];

is the path to my pvrtc file. This same exact code setup works fine if i switch it back to png and use Texture2D so I don't think its related to the path.
Quote this message in a reply
Member
Posts: 161
Joined: 2005.07
Post: #4
Could the channel-weighting flag have something to do with it? I never used that flag when I made PVR textures.
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #5
The PVRTC texture tool can create PVR or Raw formatted files. You're creating Raw files without any kind of header, but then trying to load PVR files with a header. You need to add "-f PVR" to your texturetool command to create a PVR file over a Raw file.

Using Texturetool to Compress Textures: https://developer.apple.com/iphone/libra...-CH108-SW1

Quote:The default format is Raw, which is equivalent to the format that texturetool produced under iPhone SDK 2.0 and 2.1. This format is raw compressed texture data, either for a single texture level (without the -m option) or for each texture level concatenated together (with the -m option). Each texture level stored in the file will be at least 32 bytes in size, and must be uploaded to the GPU in its entirety.

The PVR format matches the format used by the PVRTexTool found in Imagination Technologies’s PowerVR SDK. Your application must parse the data header to obtain the actual texture data. See the PVRTextureLoader sample for an example of working with texture data in the PVR format.

PVRTextureLoader: https://developer.apple.com/iphone/libra...TS40008121
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #6
Thanks. I will try that when I get home from work. If it works I will let you know.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #7
This worked. Doesn't look very good though. I really need to find out a firm # for the limit of 1024x1024 texture atlases that a first gen iphone will handle ok. My 2nd gen touch seems to handle what I have now just fine. I will probably eventually end with 3 and one 1024x512 one. Along with that I have about 12 short wav files and 15 mp3 files. It amounts to 28 megs. Adhoc build file for reference is 28.5 megs uncompressed. Anyone know how that weighs in?
Quote this message in a reply
Member
Posts: 161
Joined: 2005.07
Post: #8
Doesn't the iPhone only allow square textures?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #9
PVRTC textures have to be square, because the IMG_texture_compression_pvrtc spec says so.

Other texture formats can be non-square.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Move in direction of camera MikeD 3 4,588 Aug 18, 2010 07:33 AM
Last Post: MikeD
  glTranslate or glOrtho to move camera on a 2D game? riruilo 6 6,820 Sep 22, 2009 12:59 PM
Last Post: riruilo
  Make the terrain move with the character chrism 9 4,498 May 20, 2009 04:15 PM
Last Post: chrism
  how can I move out this bar please ? imaumac 5 3,496 Oct 12, 2008 08:14 PM
Last Post: imaumac