Merge pull request #179 from MattTuttle/fix-gl-ios

Fixes for iOS (lime:next)
This commit is contained in:
Joshua Granick
2014-07-08 10:32:07 -07:00
3 changed files with 57 additions and 3 deletions

View File

@@ -58,6 +58,8 @@
</section>
<file name="src/system/ios/System.mm" if="ios" />
<file name="src/app/UpdateEvent.cpp" />
<file name="src/graphics/PNG.cpp" />
<file name="src/graphics/RenderEvent.cpp" />

View File

@@ -1131,7 +1131,7 @@ namespace lime {
value lime_gl_get_shader_precision_format(value inShader,value inPrec) {
#ifdef lime_GLES
#ifdef LIME_GLES
int range[2];
int precision;
@@ -1519,7 +1519,7 @@ namespace lime {
value lime_gl_clear_depth(value depth) {
#ifdef lime_GLES
#ifdef LIME_GLES
glClearDepthf(val_number(depth));
#else
glClearDepth(val_number(depth));
@@ -1568,7 +1568,7 @@ namespace lime {
value lime_gl_depth_range(value inNear, value inFar) {
#ifdef lime_GLES
#ifdef LIME_GLES
glDepthRangef(val_number(inNear), val_number(inFar));
#else
glDepthRange(val_number(inNear), val_number(inFar));

View File

@@ -0,0 +1,52 @@
#import <UIKit/UIKit.h>
#import <string>
namespace lime
{
FILE *OpenRead(const char *inName)
{
FILE *result = 0;
if (inName[0]=='/')
{
result = fopen(inName,"rb");
}
else
{
NSString *assetPath = [@"assets" stringByAppendingPathComponent:[NSString stringWithFormat:@"%s", inName]];
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSString *path = [resourcePath stringByAppendingPathComponent:assetPath];
// search in documents if not in the resource bundle
if ( ! [[NSFileManager defaultManager] fileExistsAtPath:path])
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [paths objectAtIndex:0];
path = [documentDir stringByAppendingPathComponent:assetPath];
}
result = fopen([path UTF8String],"rb");
}
return result;
}
FILE *OpenOverwrite(const char *inName)
{
NSString *str = [@"assets" stringByAppendingPathComponent:[NSString stringWithFormat:@"%s", inName]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [paths objectAtIndex:0];
NSString *path = [documentDir stringByAppendingPathComponent:str];
// create any directories if they don't exist
[[NSFileManager defaultManager] createDirectoryAtPath:[path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:NULL];
FILE * result = fopen([path UTF8String],"w");
return result;
}
}