-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix iOS orientation #1477
Comments
I just came across this issue. |
I founded this bug at this moment. We develop a game and we use landscape orientations only. When the orientation change we flip the game's board and draw it in the good way but the native iOS things (volume and brightness change, popups, notifications) was upside down. I used this workaround and the problem is solved. Maybe you can implement something like this: |
hey @erinnovations, thanks for posting your solution. |
I'm pushing this back to 0073. |
The given solution is not working good for iPad3's retina display. There is an unknown situation why glView not appearing in the right position. My updated workaround (maybe helps you in the final solution): // ORIENTATION HACK
// remove the glview from the UIWindow, which is where openFrameworks puts it
[ofxiPhoneGetGLView() removeFromSuperview];
// create a plain old UIView that is the same size as the app
// just use OF sizes as our reference, everything should work out
CGRect mainFrame = CGRectMake(0, 0, CurrentConfig::CC_GAME_WIDTH, CurrentConfig::CC_GAME_HEIGHT);
mMainView = [[UIView alloc] initWithFrame:mainFrame];
// grab the glView and rotate/position it so it looks correct
UIView* glView = ofxiPhoneGetGLView();
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(M_PI_2);
glView.transform = CGAffineTransformTranslate(landscapeTransform, -128, -128); //A transform hack. I don't understand why -128,-128, but this works.
// glView goes on our main view to prevent wonky resizing
[mMainView addSubview:glView];
// root controller has main view as its view
mRootViewController = [[LandscapeViewController alloc] init];
mRootViewController.view = mMainView;
// and finally we set the root view controller
// which will make mMainView the window's primary view
// all other views are then added as subviews of mMainView
// NOT as subviews of the UIWindow or the EAGLView
ofxiPhoneGetUIWindow().rootViewController = mRootViewController; |
ive got glView orientation working correctly now... to move forward with this change, so im thinking a couple extra methods need to be created, and adding a message to also thinking of moving |
had another think and decided against adding new orientation methods to ofAppiPhoneWindow... probably would confuse things. instead, when now calling ofAppiPhoneWindow::setOrientation a message is displayed in the console to use ofxiPhoneSetOrientation instead. ofxiPhoneSetOrientation and ofxiPhoneGetOrientation now call methods on ofxiPhoneViewController to make orientation changes. think this approach will have minimal effect on legacy apps and its easy to make the adjustment to get orientation working again. |
We seem to be having an orientation issue here: http://forum.openframeworks.cc/index.php/topic,11484.msg50874.html#msg50874 I'm not sure if it's an iOS 6 issue. For our project we have it so the openGL should never rotate, but we should be able to have a iOS native GUI that can rotate to all orientations. This previously worked until the update. |
hey @cerupcat, there have been changes in iOS6 that deal with orientation differently. iOS orientation is still an outstanding issue in OF and when it gets resolved, it should also work on iOS6. |
Yeah, I noticed that setting the orientation in the plist will cause the whole thing to rotate to those orientations. Therefore, the only option seems to be setting it in code so that it can be controlled. If you don't give an orientation, it'll rotate the whole window including the openGL view and it'll cut off the openGL view since it's not resized. So right now it seems the only supported orientations are portrait or landscape, but not both. I'll try to look into it a bit more, but may have to revert to a previous OF for now. |
.@cerupcat did you get this fixed on yours? can anyone confirm if this works? Thanks |
Hi,
-(void) applicationDidFinishLaunching:(UIApplication *)application {
..
in this solution you don't have to rotateXY or transform touches. Roee |
this should be closed because of this #931 |
Closed by #931 thanks roy! |
currently when setting orientation on ios,
the glView remains in portrait mode but everything drawn in the glView is flipped or rotated depending on the specified orientation.
a more elegant method would be to rotate and resize the glView directly to a orientation.
and as far as OF is concerned, its always in OF_ORIENTATION_DEFAULT mode but the glView is adjusted.
this way you never have to flip or rotate any coordinates.... which will cut out a lot of orientation bugs which currently exist.
The text was updated successfully, but these errors were encountered: