Question

Background

In our app, we use a PNG sprite sheet where each sprite is just used as a mask. These are successfully loaded using GLKTextureLoader. When iOS 7 reached the 5th/6th beta, something appeared to change in the way GLKTextureLoader works, as suddenly all our PNGs started rendering incorrectly, as though there was something wrong with the alpha premultiplication.

After bug reports were submitted, and no response was received from Apple (and the problem is, worryingly, still present in the live release of iOS 7), we have decided to convert our PNGs to a PVR format.


Problem

When trying to load the PVR texture using GLKTextureLoader:

NSDictionary *options = @{ GLKTextureLoaderOriginBottomLeft : @YES, GLKTextureLoaderApplyPremultiplication : @NO };
GLKTextureInfo *textureInfo = [GLKTextureLoader textureWithContentsOfURL:url options:options error:&error];

it fails with error 12 (GLKTextureLoaderErrorDataPreprocessingFailure). What is involved in this 'preprocessing' step, and what could be the problem?

Here are some things I have checked:

  • The URL is valid
  • The file extension is .pvr
  • The image has square POT dimensions (512x512)
  • I have tried multiple PVR formats, including compressed and uncompressed (PVRTC 4bpp, RGBA8888, L8, A8)
  • I have put glErrorChecks before & after the textureWithContentsOfURL:options:error:, but nothing is logged (presumably GLKTextureLoader is consuming the GL error, or the error is unrelated to OpenGL)

This answer indicates that this can be caused by file corruption. This makes me wonder if I'm somehow generating the PVR incorrectly. I am using Imagination's PVRTexToolGUI to convert the PNG:

  1. Open the PNG in PVRTexToolGUI
  2. Premultiply the alpha (although I have also tried it without this step)
  3. Encode the current texture to a new format (have tried multiple formats, as described above)
  4. Save the texture out as a .pvr file.
Was it helpful?

Solution

There are 2 versions of PVR file: the new and the legacy one. Try to save your PVR textures in different file format (save as legacy).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top