How to stop the GLView animation and restart it ?
Hi,
I am new to OpenGL ES application. I am trying to make an animation with 3D objects in .obj format.
The problem in my application are
1. I'm not able to stop the animation.
2. When ever i call the startAnimation() function in Class A it runs for the first time, it start crashes from second time onwards. Instead of Animation If i try to call an Audio it works.
Help me to solve the two issues. Below is the code where the issues arises.
//Class A
-(IBAction)play {
CGRect rect = [[UIScreen mainScreen] bounds];
glView = [[GLView alloc] initWithFrame:rect];
GLViewController *theController = [[GLViewController alloc] init];
self.controller = theController;
[theController release];
glView.controller = controller;
glView.animationInterval = 1.0 / kRenderingFrequency;
[glView startAnimation];
[self.view addSubview:glView];
[glView release];
}
-(IBAction)stop {
[glView stopAnimation];
[glView release];
[self.audioPlayer stop];
}
//class GLView
- (void)startAnimation {
animationInterval = 0.0;
animationTimer = nil;
animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
}
- (void)stopAnimation {
[animationTimer invalidate];
animationTimer = nil;
animationInterval = 0.0;
}
|