-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiOS.mm
69 lines (53 loc) · 2.04 KB
/
iOS.mm
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
#ifdef IOS
#import "App.h"
@implementation iphoneViewerAppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *info = [bundle infoDictionary];
NSString *prodName = [info objectForKey:@"CFBundleExecutable"];
std::string appname = std::string([prodName UTF8String]);
//printf("appname = %s\n", appname.c_str());
NSString *epath = [[NSBundle mainBundle] executablePath];
std::string exePath = std::string([epath UTF8String]); //NSString to std::string
exePath = exePath.substr(0, exePath.find_last_of("/\\"));
//printf("exe_path = %s\n", exe+path.c_str());
//NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
//NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Populator"];
//NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"Files"];
//NSLog(@"Source Path: %@\n Documents Path: %@ \n Folder Path: %@", sourcePath, documentsDirectory, folderPath);
App app;
App::mFile = exePath+"/assets/demo.rml";
App::init();
[NSTimer scheduledTimerWithTimeInterval:1.0/30.0 target:self selector:@selector(updateScene) userInfo:nil repeats:YES];
}
- (void)updateScene
{
if(App::mActive){
App::do_frame();
}
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
-(void)applicationWillTerminate:(UIApplication *)application
{
App::exit();
}
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
//Use a basic low-pass filter to only keep the gravity in the accelerometer values
accel[0] = acceleration.x * 30.0 + accel[0] * (1.0 - 0.1);
accel[1] = acceleration.y * 30.0 + accel[1] * (1.0 - 0.1);
accel[2] = acceleration.z * 30.0 + accel[2] * (1.0 - 0.1);
}
- (void)dealloc
{
//[super dealloc];
}
@end
#endif //IOS
*/