// @ Project : hello eagl ++ // @ File Name : eaglAppDelegate.mm // @ Date : 2008-4-8 // @ Author : kongfu.yang // @ Company : http://www.play3d.net // @ Copyright : 2008-4, Example source license. // By keep this header comment, // you may use this source file in your project for non-commercial or commercial purpose. #import "eaglAppDelegate.h" #import "eglView.h" #include "callbacks.h" @implementation eaglAppDelegate @synthesize window; @synthesize contentView; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Create window self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Set up content view // mode: window with status bar //self.contentView = [[[eglView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]; // mode: full screen //self.contentView = [[[eglView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; UIView * glview = [[eglView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [window addSubview:glview]; // Show window [window makeKeyAndVisible]; //getApp()->rendering(); timer = [NSTimer scheduledTimerWithTimeInterval:1.0/24 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES]; //Configure and start accelerometer [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 10)]; [[UIAccelerometer sharedAccelerometer] setDelegate:self]; } - (void)dealloc { [contentView release]; [window release]; [super dealloc]; } - (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration { getApp()->accelerating(acceleration.x, acceleration.y, acceleration.z); } - (void) onTimer:(NSTimer*)timer { getApp()->rendering(); } @end