gamnit :: TextureAsset :: glkit_load
path
with GLKit services
# Load image at `path` with GLKit services
private fun glkit_load(path: NSString, premultiply: Bool): GLKTextureInfo
in "ObjC" `{
// The premultiplication flag has been inverted between iOS 9 and 10
NSNumber *premultiply_opt;
NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"10.0.0" options: NSNumericSearch];
if (order == NSOrderedSame || order == NSOrderedDescending) {
// >= 10
premultiply_opt = premultiply? @NO: @YES;
} else {
// < 10
premultiply_opt = premultiply? @YES: @NO;
}
NSDictionary *options = @{GLKTextureLoaderApplyPremultiplication: premultiply_opt};
NSError *error;
GLKTextureInfo *spriteTexture = [GLKTextureLoader textureWithContentsOfFile: path options: options error: &error];
if (error != nil) NSLog(@"Failed to load texture: %@", [error localizedDescription]); // TODO return details to Nit
return spriteTexture;
`}
lib/gamnit/display_ios.nit:81,2--102,3