I have an iPad app and am drawing the main view with openGL and I want to animate my own change when the device is rotated.
Note that this app only draws occasionally, it is not constantly animating. Also my scene is a (very complex) 2D drawing, not 3D. I just want it to simply rotate around the display center during device orientation change, maintaining correct aspect ratio.
At the moment I just have the following code:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// nothing yet
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
IMMainView *mv = (IMMainView *)self.view;
[mv createRenderbuffer];
[mv drawView];
}
I just re-create the OpenGL render buffer to match the new width and height once the rotation completes.
The default iOS behavior seems to rotate the view but also stretches it weirdly as the aspect ratio changes.
I can animate my drawing parameters to make something better appear during the transition, but I don't understand (1) how to stop iOS animating my layer and (2) how to set up an animation loop from these method calls that matches the iOS animation.
For example, during the animation, are the actual view width and height being changed progressively?
Also a possibly issue is the question of when to re-create the render buffer, because if the OpenGL buffer does not match the iOS view bounds then the pixel aspect ratios are not right and the drawing looks bad.
Any help would be appreciated.