gloo gloo - 1 month ago 18
iOS Question

updating to iOS 10.1.1 broke my game

I have been developing a metal game for ios in Xcode using swift 3. Yesterday everything was working fine and then over lunch I updated my iPad to iOS 10.1.1 and now all of my textures are flipped upside down and the colors are darker. I load my textures with an

MTKTextureLoader
. I did not change any code before the update. Any ideas on what might have happened? I also updated my Mac but not sure if Xcode was updated.

Answer

Some of the default behavior of MTKTextureLoader changed between iOS 9 and iOS 10. You may need to adjust the options dictionary you pass when loading textures. For example:

let options = [MTKTextureLoaderOptionSRGB : false as NSObject,
               MTKTextureLoaderOptionOrigin : MTKTextureLoaderOriginFlippedVertically as NSObject]

The first option causes the image data to be treated as not in the sRGB colorspace, while the second option unconditionally flips the texture vertically. You should explore the possible values for these options, as it may be more appropriate to adjust your images or your shaders rather than your texture loading options.

These changes should not affect apps that were compiled for iOS 9. The new behavior should only occur when re-compiling apps for iOS 10 and newer.