GLKTextureLoader只能加载一个纹理

时间:2017-06-19 23:09:37

标签: ios objective-c opengl-es glkit glktextureloader

我在通过加载纹理方法加载纹理时出现问题。

+(Texture*) loadTexture: (NSString*) name path: (NSString*) path{
    CGImageRef imageReference = [[UIImage imageNamed:path] CGImage];

    GLKTextureInfo* textureInfo = [GLKTextureLoader textureWithCGImage:imageReference options:nil error:NULL];

    Texture* texture = [[Texture alloc] init:textureInfo];

    NSLog(@"width: %i height: %i data: %p", [texture Width], [texture Height], [texture getTextureInfo]);

    if(!Textures) Textures = [[NSMutableDictionary alloc] init];

    [Textures setObject:texture forKey:name];
    NSLog(@"adding key %@ to dictionary with pointer %p", name, Textures);
    NSLog( @"%@", Textures );

    return texture;
}

第一次调用load纹理方法时,一切都很好,但是任何后续的加载纹理调用都无法初始化textureInfo,NSLog显示&#34; width:0 height:0 data:0x0&#34; < / p>

1 个答案:

答案 0 :(得分:0)

我弄清楚它为什么不起作用,这里是答案https://stackoverflow.com/a/13948618/7914426

的链接
相关问题