iosopengl-espvrtc

Convert NPOT PVR texture to POT within iOS


I would like to manually load NPOT PVR textures on iOS (I don't mean loading the texture in OpenGL memory, I mean loading it in a custom data structure that allows accessing the image data in order enlarge the canvas and save it again as a new PVR).

I am asking this because we are implementing an OpenGL iOS application with lots of background textures (480 x 320 on non retina displays). We intend to store this textures as NPOT PVR files, so we have memory gains on 3GS+ iPhones.

3G- iPhone cannot load NPOT PVR textures in non OpenGL memory. My intentions are to implement a preprocessing step for 3G- devices that converts all NPOT PVRs textures to POT PVRs and stores them on the app's Cache folder.

Is it possible to load and process a PVR in this way? For example, a TexturePacker generated PVR.


Solution

  • Sure it is.

    1. Decompress the file format.
    2. Scale raw image data
    3. Compress new scaled data and save

    For step one, see https://github.com/Volcore/quickpvr or PowerVR's SDK.

    For step three there is no publicly available documentation or implementation of PVRTC compression. So you have several options. Use the combination of class-dump and otx to decompile Apple s texturetool (not advisable), or (and probably easier) write your own encoder based on whatever specification of the file format you can conjure from step 1.

    However, given your situation I would just do this all as a preprocessed step and include two versions of your textures along with your app.