我正在编写一个3D模型查看器。但我不能有纹理。
每次我尝试运行此代码:
NSDictionary *options = @{ GLKTextureLoaderSRGB : @YES };
NSError *error;
NSString *path = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"png"];
GLKTextureInfo *texture = [GLKTextureLoader textureWithContentsOfFile:path options:options error:&error];
if(texture == nil){
NSLog(@"error loading texture : %@", error.localizedDescription);
}
纹理总是无效的。我尝试了选择:也是。 图像没有错误。它是2048x2048 png。适用于其他应用程序。
错误是:GLKTextureLoaderErrorDomain错误12
它与其他图像一起出现同样的错误。
解决。
png格式引起的问题。我将图像格式更改为jpg并解决了问题。