Ios 在视网膜上加载带有“textureWithContentsOfFile”的纹理显示不工作
我对IOS开发的GLKit有一个奇怪的问题 以下是我的纹理加载程序方法:Ios 在视网膜上加载带有“textureWithContentsOfFile”的纹理显示不工作,ios,textures,retina-display,glkit,Ios,Textures,Retina Display,Glkit,我对IOS开发的GLKit有一个奇怪的问题 以下是我的纹理加载程序方法: (id)initWithFile:(NSString *)fileName effect:(GLKBaseEffect *)effect { if ((self = [super init])) { self.effect = effect; NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
(id)initWithFile:(NSString *)fileName effect:(GLKBaseEffect *)effect {
if ((self = [super init])) {
self.effect = effect;
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
GLKTextureLoaderOriginBottomLeft,
nil];
NSError * error;
NSString *path0 = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
NSLog(@"Path for Image: %@",path0);
self.texture0Info = [GLKTextureLoader textureWithContentsOfFile:path0 options:options error:&error];
if (self.texture0Info == nil) {
NSLog(@"Error loading file: %@", [error localizedDescription]);
return nil;
}
TexturedQuad newQuad;
newQuad.bl.geometryVertex = CGPointMake(0, 0);
newQuad.br.geometryVertex = CGPointMake(self.texture0Info.width/2, 0);
newQuad.tl.geometryVertex = CGPointMake(0, self.texture0Info.height/2);
newQuad.tr.geometryVertex = CGPointMake(self.texture0Info.width/2, self.texture0Info.height/2);
newQuad.bl.texture0Vertex = CGPointMake(0,1);
newQuad.br.texture0Vertex = CGPointMake(1,1);
newQuad.tl.texture0Vertex = CGPointMake(0,0);
newQuad.tr.texture0Vertex = CGPointMake(1,0);
self.quad = newQuad;
self.contentSize=CGSizeMake(self.texture0Info.width, self.texture0Info.height);
}
return self;
}
我从GLKViewController调用这个方法
-(void)addBubbleImage{
SpriteThings * bubbleImage = [[ SpriteThings alloc]initWithFile:@"Rectangler.png" effect:self.effect];
bubbleImage.position=GLKVector2Make(self.view.bounds.origin.x, self.view.bounds.origin.y);
[self.screenThings addObject:bubbleImage];
}
奇怪的是,它在非视网膜显示器上工作,图像加载正确。但在视网膜显示器上,无论是在设备上还是在模拟器上都没有显示任何东西。我有Rectangler.png和Rectangler@2x.png我的项目中的文件位于同一目录中。但还是卡住了。你觉得怎么样?问题越来越奇怪了。它适用于iPhone4S、iPhone5、iPad2和iPadRetina。而且不适用于iPhone 5s、iPhone 6、iPhone 6 Plus和iPad Air。İOS 7.1和8.1的结果相同。我想我发现了孤独。它与64位体系结构相关。我将所有与CGPoint相关的内容都更改为GLKVector2,并解决了问题。