1

I'm using GLKLoadTexture to load an atlas into my OpenGL based application.

When I load the texture on a device with iOS 10 (iPad mini Retina, iPhone 7) the colors show up exactly as they are in the PNG. But when I load it on an older device on iOS 9 or lower (iPod touch 5G, iPad 2), the red and blue channels are flipped!

This happens on the Simulator as well when I choose the respective iOS versions for any (64 bit or 32 bit) device.

Here's my texture loading code:

UIImage *imageRef = [UIImage imageNamed:@"TextureMap"];
GLKTextureInfo *_texture = [GLKTextureLoader textureWithCGImage:imageRef.CGImage options:nil error:&error];

if(error)
{
    NSLog(@"Texture Error:%@", error);
}
glBindTexture(GLenum(GL_TEXTURE_2D), _texture.name);

After this, the code is handed over to C++ to do the rest (the program only uses a single texture), but I encountered this same problem in a Swift-based application as well with similar code.

  • I would suggest you to avoid everything prefixed GLK on iOS except geometry (matrix, vectors). Since you say so pass it to C++ anyway you would do best to create the texture from UIImage the old way. Try something like this http://stackoverflow.com/questions/14362868/convert-an-uiimage-in-a-texture – Matic Oblak May 12 '17 at 06:09
  • Thanks, it worked! Why is GLKit so buggy? – ToxicCaves64 May 12 '17 at 18:06
  • I am not sure it is that buggy. It is used by other kits which at least seem to work. But generally it is completely useless and is a failed attempt to make openGL integration easier for developers. OpenGL has been evolving for very many years and is as it is for a reason. GLKit has not and in my opinion it should be avoided at all costs. – Matic Oblak May 12 '17 at 18:12

0 Answers0