GLKTextureLoader textureWithContentsOfFile: fails for the first time

断了今生、忘了曾经 提交于 2019-12-13 02:54:15

问题


I am using GLKTextureLoader to load image textures into a sprite.

When I run the following code and load two sprites...

NSString *pathToImage = [NSString stringWithFormat:@"%@/defaultProject/images/%@", [Util applicationDocumentsDirectory], fileName];
NSLog(@"path: %@", pathToImage);
self.textureInfo = [GLKTextureLoader textureWithContentsOfFile:pathToImage options:options error:&error];
if (self.textureInfo == nil) 
{
    NSLog(@"Error loading file: %@", [error localizedDescription]);
    return;
}

... it fails for the first image but not for the second.

The error is:

Error loading file: The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 12.).

Does anyone know what this error means? I haven't found any information on code 12.

Thanks in advance!


回答1:


Error code 12 means GLKTextureLoaderErrorDataPreprocessingFailure as per (Apple Docs)

I think cause of error is a file corruption. Try to re-save your corrupted image.



来源:https://stackoverflow.com/questions/11586702/glktextureloader-texturewithcontentsoffile-fails-for-the-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!