0

I have an issue with auto rotation in where I want a specific view to stay always in portrait mode.

One suggestion I found was to just rotate the view back when a landscape rotation is detected like this:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
                                         duration:(NSTimeInterval)duration
{
    float rotation;

    if (toInterfaceOrientation==UIInterfaceOrientationPortrait) {
        rotation = 0;
    } 
    else 
    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) {
        rotation = M_PI_2;
    } 
    else
    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight) {
        rotation = -M_PI_2;
    }

    videoWindow.transform = CGAffineTransformMakeRotation(rotation);
    openGLView.transform = CGAffineTransformMakeRotation(rotation);

}

So the result is that, whenever the user changes to landscape mode the video view is correctly rotated back so it will look good as if it didn't rotate from the first place.

My issue is with the OpenGL view. When I rotate it back the contents of my OpenGL drawings get distorted until they fail and I get an error on the log saying "Failed to make complete framebuffer object 8cd6"

Now, if I comment the previous code and let the viewcontroller autorotate the OpenGL view it does get rotated and nothing gets distorted (but in landscape the measures don't fit.

So my question is, how does apple rotate things on device rotation detected so that I can simulate the exact process backwards to achieve a simulated rotation locked-OpenGL view.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Pochi
  • 13,391
  • 3
  • 64
  • 104
  • In Xcode you can set the rotations that will be adjusted for, why not just do that? – James Black May 29 '12 at 04:05
  • http://stackoverflow.com/questions/7353789/ios-disable-autorotation-for-a-subview – Arun May 29 '12 at 05:10
  • http://stackoverflow.com/questions/4040398/ios-cocos2dbox2dhow-to-disable-auto-rotation – Arun May 29 '12 at 05:11
  • these are not related to what I am looking for. The issue is that there has to be a way that apple uses to rotate elements that works well with opengl. The auto rotate code rotates my glkview and nothing inside gets distorted. – Pochi May 29 '12 at 07:33

0 Answers0