-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGLPTexture+NamedTexture.m
52 lines (42 loc) · 1022 Bytes
/
GLPTexture+NamedTexture.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// GLPTexture+NamedTexture.m
// OpenGLPlus
//
// Created by Maximilian Christ on 24/12/13.
// Copyright (c) 2013 McZonk. All rights reserved.
//
#import "GLPTexture+NamedTexture.h"
#if defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE > 0)
#import "GLPTexture+UIImage.h"
#endif
@implementation GLPTexture (NamedTexture)
+ (instancetype)textureNamed:(NSString *)name
{
#if defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE > 0)
UIImage *image = [UIImage imageNamed:name];
if(image != nil)
{
return [self textureWithUIImage:image];
}
#endif
return [self textureNamed:name bundle:nil];
}
+ (instancetype)textureNamed:(NSString *)name bundle:(NSBundle *)bundle
{
if(bundle == nil)
{
bundle = NSBundle.mainBundle;
}
NSString *path = [bundle pathForResource:name ofType:nil];
if(path == nil)
{
return nil;
}
#if defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE > 0)
UIImage *image = [UIImage imageWithContentsOfFile:path];
return [self textureWithUIImage:image];
#else
return nil;
#endif
}
@end