Landscape only on iPad issue

Hi there,

The app I’m developing is landscape only. I have it setup as so through the Xcode project settings.

On boot the viewport and touch positioning is out by 90 degrees. Once you rotate the iPad it fixes the issue. I have tried setting ofSetOrientation() on the first frame of update() but that doesn’t work, the only thing that kicks it into working properly is physically rotating the iPad

I’ve been scratching my head on this one for a while now, and it’s driving me a bit batty! Any hints of ways to look into this, or better still a solve would be greatly appreciated!



This might be a problem related on how you are creating the window in main.cpp.
There is a specific windowSettings type available for iOS.

ofiOSWindowSettings settings;
// enables retina resolution if the device supports it.
settings.enableRetina = true;
// enables depth buffer for 3d drawing.
settings.enableDepth = true;
settings.enableAntiAliasing = false;
// enables native view orientation.
settings.enableHardwareOrientation = true;
// enables native orientation changes to be animated.
settings.enableHardwareOrientationAnimation = false;
// type of renderer to use, ES1, ES2, etc.
settings.glesVersion = OFXIOS_RENDERER_ES2;
// screen orientation
settings.setupOrientation = OF_ORIENTATION_90_LEFT;
//settings.setupOrientation = OF_ORIENTATION_90_RIGHT;
// enable multitouch
settings.enableMultiTouch = true;

If you use OF_ORIENTATION_90_LEFT on the settings.setupOrientation parameter, this should allow you to use landscape mode.

I think I ran into this too on my last app.
I think I both set it via the settings as @mkrebs mentioned but also via the Xcode properties

Something like this but selecting just the orientations you want.

I also think it is good to note that the OF orientation does not correspond to the physical orientation. ie: OF_ORIENTATION_90_LEFT is Landscape Right ( I believe ).

I have setup the Xcode settings as above (but for the the orientation as landscape). I have also set the up as above (as well as experimenting with different variations).

OF doesn’t know what orientation the device is in on launch (ofGetWidth() & Height don’t provide a distinction either), as such, half of the time (dependent on whether my ofSetOrientation() call matches the device orientation) the viewport and touch coords are out by 90 degrees until a rotation happens.

hmm going to ping @danoli3 on this - have you tried using one of the nightly builds as it could be fixed there?

At the bottom of:

The nightly build was the same, I have started a conversation with @danoli3 around paying him to resolve this issue, and would appreciate assistance as needed to get the solve included into core OF for future OF builds

I can confirm the problem getting width and height, but you can simply check it and swap width and height, to solve the issue

int xMax = ofGetWindowWidth();
int yMax = ofGetWindowHeight();
if (xMax < yMax)
	int swap = xMax;
	xMax = yMax;
	yMax = swap;

I went for “Landscape Right” for my App, it seems to work better with iPad accessories.

settings.setupOrientation = OF_ORIENTATION_90_RIGHT;

For the “Device orientation” in xCode I also use “Landscape Right”.

Finally, I had to add the following line at addons/ofxiOS/core/ at line number 172, in order to ensure the correct behaviour.

interfaceOrientation = UIInterfaceOrientationLandscapeRight;

Hope this helps. Good luck.

Ok, so… I have a workaround…
this will allow you to have a landscape only app on iPad, it will start in default, and then on rotation of device the screen will rotate (but without animation)

Using these settings in the Xcode Project file:

and then in main:

int main() {

    //  here are the most commonly used iOS window settings.
    ofiOSWindowSettings settings;
    settings.enableRetina = true; // enables retina resolution if the device supports it.
    settings.enableDepth = false; // enables depth buffer for 3d drawing.
    settings.enableAntiAliasing = true; // enables anti-aliasing which smooths out graphics on the screen.
    settings.numOfAntiAliasingSamples = 4; // number of samples used for anti-aliasing.
    settings.enableHardwareOrientation = false; // enables native view orientation.
    settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated.
    settings.glesVersion = OFXIOS_RENDERER_ES2; // type of renderer to use, ES1, ES2, etc.
    settings.windowControllerType = ofxiOSWindowControllerType::GL_KIT; // Window Controller Type
    settings.colorType = ofxiOSRendererColorFormat::RGBA8888; // color format used default RGBA8888
    settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE; // depth format (16/24) if depth enabled
    settings.stencilType = ofxiOSRendererStencilFormat::STENCIL_NONE; // stencil mode
    settings.enableMultiTouch = true; // enables multitouch support and updates etc.

	return ofRunApp(new ofApp);

and then in

in setup add:


and have this function in ofApp too:

void ofApp::deviceOrientationChanged(int newOrientation){
    else if(newOrientation==OF_ORIENTATION_90_LEFT){
    int nextOrientation = ofGetOrientation();
    cout<<"orientation changed "<<newOrientation<<" "<<nextOrientation<<endl;