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!

Thanks,
Miles

Hi.

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;
ofCreateWindow(settings);

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.
OZXXP

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 main.mm 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:
https://openframeworks.cc/download/

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/ofxiOSViewController.mm at line number 172, in order to ensure the correct behaviour.

interfaceOrientation = UIInterfaceOrientationLandscapeRight;

Hope this helps. Good luck.