I'm not sure why the synchronous call was crashing, but this async version of my function is working nicely -- textures loading and showing correctly in the glview.
-(GLint)prepareTextureWithImage:(UIImage *)image andName:(NSString *)name
{
NSLog(@"[INFO] image has CGImage %@", image.CGImage);
NSLog(@"[INFO] image has size %f, %f", image.size.width, image.size.height);
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
GLKTextureLoaderOriginBottomLeft,
nil];
NSError *error;
GLKTextureLoader *textureloader = [[GLKTextureLoader alloc] initWithSharegroup:self.context.sharegroup];
GLKTextureInfo *myTexture;
[textureloader textureWithCGImage:image.CGImage options:nil queue:nil completionHandler:^(GLKTextureInfo *textureInfo, NSError *error) {
if(error) {
NSLog(@"[ERROR] Error loading texture from image: %@",error);
}
else {
NSLog(@"[INFO] GlkitViewController prepared texture %@", textureInfo);
[textures setObject:textureInfo forKey:name];
}
}];
}