Take the 2-minute tour ×

I use GLKTextureLoader to load a 32bit PNG (created in GIMP). The GLKTextureInfo returned is showing GLKTextureInfoAlphaStateNonPremultiplied for the alphaState on both the simulator and iPad. Experimenting with glBlendFunc and GLKTextureLoader I can get it work on the iPad or simulator, but not both!

With no options to GLKTextureLoader, and with the following blend func:


I get on the iOS Simulator (notice the glow on the text is bright)

enter image description here

And on a 4th iPad (notice the glow on the text is dark)

enter image description here

Why the difference? The alphaState is the same. What could it be?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I found the answer on an Apple Discussion.

I have the exact same problem. XCode will convert PNG images so that the header chunk is CgBI (instead of IHDR), and that confuses 3rd party libs like libpng, since a character in Apple's header indicates that the data is in a private format. This operation only takes place for the target device - the simulator is unaffected. There are 4 ways to work around the issue (from easiest to hardest).

1) Rename your images to something else (eg. .ppng), and the XCode packaging tool will ignore your file.

2) According to the following link (http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp), you need to add the following build settings defintion for each target. IPHONEOPTIMIZEOPTIONS=-skip-PNGs I'm embaressed to say that I still haven't figured out where in XCode project settings to add this.

3) Teach your PNG decoder to handle Apple's CgBI format.

4) Use the Cocoa UIImage classes or the Texture2D.m class.

EDIT: In "Packaging" of "Build Settings" I have found a "Compress PNG Files" option that defaults to "Yes".

share|improve this answer
If your own answer helped you to fix your bug please accept it. –  keaukraine Nov 28 '12 at 8:24
There is a wait-time before I can accept my own answer as the answer; says I can accept it tomorrow. –  Mr. Smith Nov 28 '12 at 16:24
What I still don't understand, though, is why the output differs between device and simulator. Shouldn't the "Compress PNG Files" option affect both environments? –  PrimaryFeather Feb 21 '13 at 10:23
add comment

Your Answer


