使用" textureWithContentsOfFile"加载纹理在Retina显示器不工作

时间:2015-02-08 19:58:39

标签: 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:
                              [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文件。但仍然卡住了。你觉得怎么样?

0 个答案:

没有答案