iOS Create non-rotating GLView with rotating iOS View Controller?

I have an iOS app and I’d like the openGL view to not respond to device orientation changes (stays static), but have any presented views or view controllers rotate to device orientation. So far I’ve been unable to get view controllers to be able to rotate independently of the openGL view. Any tips for getting this working?

I like to overwrite the default ofxiOSAppDelegate so I can later add Google Analytics and other tracking, as well as customize the orientation per view. Here’s what I use in my main.mm file to gain better control over orientation shifts, as well as antialiasing:

int main() {
	ofAppiOSWindow *window = new ofAppiOSWindow();
	window->enableAntiAliasing(4);
	window->enableRendererES2();
	window->enableRetina();
	window->disableHardwareOrientation();
	window->disableOrientationAnimation();
	window->setOrientation(OF_ORIENTATION_90_RIGHT);
	ofSetupOpenGL(ofPtr(window), 1024,768, OF_FULLSCREEN);
	window->startAppWithDelegate("MyDelegate");
//	ofSetupOpenGL(window, 1024, 768, OF_FULLSCREEN);
//	ofRunApp(new ofApp());
}

Then, my Delegate extends ofxiOSAppDelegate, and my ViewController extends ofxiOSViewController, making the rest pretty fairly and easy to integrate. I have noticed some buggy behavior with iOS7 and the latest OpenGL orientations, but the above script definitely helps with the simulator being twitchy. The iOS samples in the examples folder are a great help too!

1 Like

Thanks, I’ll take a look at that method.

Do you have any basic example I could try of MyDelegate and the extending of ofxiOSAppDelegate/ofxiOSViewController?