png to pvrtc move - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: png to pvrtc move (/thread-1085.html)
png to pvrtc move - kendric - Jun 27, 2009 09:08 AM
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.
png to pvrtc move - kshep - Jun 27, 2009 09:33 AM
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.
png to pvrtc move - kendric - Jun 27, 2009 11:22 AM
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 != ((pvrTag >> 0) & 0xff) ||
gPVRTexIdentifier != ((pvrTag >> 8) & 0xff) ||
gPVRTexIdentifier != ((pvrTag >> 16) & 0xff) ||
gPVRTexIdentifier != ((pvrTag >> 24) & 0xff))
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.
png to pvrtc move - imikedaman - Jun 28, 2009 11:45 AM
Could the channel-weighting flag have something to do with it? I never used that flag when I made PVR textures.
png to pvrtc move - Bachus - Jun 28, 2009 03:53 PM
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/library/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TextureTool/TextureTool.html#//apple_ref/doc/uid/TP40008793-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.
png to pvrtc move - kendric - Jun 29, 2009 11:51 AM
Thanks. I will try that when I get home from work. If it works I will let you know.
png to pvrtc move - kendric - Jun 30, 2009 03:34 PM
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?
png to pvrtc move - imikedaman - Jul 1, 2009 03:00 AM
Doesn't the iPhone only allow square textures?
png to pvrtc move - arekkusu - Jul 1, 2009 04:49 AM
PVRTC textures have to be square, because the IMG_texture_compression_pvrtc spec says so.
Other texture formats can be non-square.