2012-07-20 108 views
0

我正在使用GLKTextureLoader将图像纹理加载到精灵中。GLKTextureLoader textureWithContentsOfFile:第一次失败

当我运行下面的代码或装载两个精灵......

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; 
} 

...它失败的第一个图像而不是第二。

的错误是:

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

有谁知道这是什么错误意味着什么?我还没有找到关于代码12的任何信息。

在此先感谢!

回答

0

错误代码12装置GLKTextureLoaderErrorDataPreprocessingFailure为全(Apple Docs

我认为错误的原因是一个文件损坏。尝试重新保存已损坏的图像。

+0

你说得对。当我更改文件并保持文件名相等时,它就可以工作。但是我可以在预览中打开文件?所以它绝对不是腐败?!唯一的区别在于文件大小。 – Chris 2012-07-21 10:05:48

+0

文件可以正常使用,但由于某种原因无法处理。重新保存相同的文件应该可以解决您的问题。 – 2012-07-21 20:52:28