From 302e45e851cdd549a8f39db91441800a0ef4861d Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 6 Mar 2011 22:49:41 +0000 Subject: [PATCH] ios: get texture loading to work, somehow. --- src/Makefile.am | 2 -- src/image.cpp | 11 ++++++++--- src/image.mm | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 src/image.mm diff --git a/src/Makefile.am b/src/Makefile.am index a7e6a6b8..292e3dd3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,5 +20,3 @@ liblol_a_SOURCES = \ debugquad.cpp debugquad.h liblol_a_CPPFLAGS = @LOL_CFLAGS@ -EXTRA_DIST = image.mm - diff --git a/src/image.cpp b/src/image.cpp index 97ed2636..a77cb065 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -16,7 +16,7 @@ #include #if defined __APPLE__ && defined __MACH__ -# +# import #elif defined USE_SDL # include # include @@ -68,8 +68,13 @@ Image::Image(char const *path) : data(new ImageData()) { #if defined __APPLE__ && defined __MACH__ - NSString *path = [[NSBundle mainBundle] pathForResource:@"ascii" ofType:@"png"]; - NSData *pngdata = [[NSData alloc] initWithContentsOfFile:path]; + NSString *fullpath = [NSString stringWithUTF8String:path]; + NSArray *chunks = [fullpath componentsSeparatedByString: @"/"]; + NSString *filename = [chunks objectAtIndex: [chunks count] - 1]; + chunks = [filename componentsSeparatedByString: @"."]; + NSString *prefix = [chunks objectAtIndex: 0]; + NSString *mypath = [[NSBundle mainBundle] pathForResource:prefix ofType:@"png"]; + NSData *pngdata = [[NSData alloc] initWithContentsOfFile:mypath]; UIImage *image = [[UIImage alloc] initWithData:pngdata]; if (!image) { diff --git a/src/image.mm b/src/image.mm deleted file mode 100644 index 2ed67980..00000000 --- a/src/image.mm +++ /dev/null @@ -1 +0,0 @@ -#include "image.cpp"