Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

[iOS] Can't get hardware orientation on startup

$
0
0

@cuinjune wrote:

Hi, I'm trying to detect the device orientation when the app is launched.

But it seems like the app always changes its orientation to OF_ORIENTATION_DEFAULT on startup regardless of its current hardware orientation.

For example, if I start an app in a landscape mode, it always changes to a default portrait mode.

Here's my example code,

in main.mm

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 = true; // 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 = true; // enables native view orientation.
    settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated.
    settings.glesVersion = OFXIOS_RENDERER_ES1; // type of renderer to use, ES1, ES2, etc.

    ofCreateWindow(settings);

	return ofRunApp(new ofApp);
}

in ofApp.mm

//--------------------------------------------------------------
void ofApp::setup(){

    switch (ofGetOrientation()) {

        case OF_ORIENTATION_DEFAULT:
            cout << "OF_ORIENTATION_DEFAULT" << endl;
            break;
        case OF_ORIENTATION_180:
            cout << "OF_ORIENTATION_180" << endl;
            break;
        case OF_ORIENTATION_90_LEFT:
            cout << "OF_ORIENTATION_90_LEFT" << endl;
            break;
        case OF_ORIENTATION_90_RIGHT:
            cout << "OF_ORIENTATION_90_RIGHT" << endl;
            break;
        case OF_ORIENTATION_UNKNOWN:
            cout << "OF_ORIENTATION_UNKNOWN" << endl;
            break;
        default:
            break;
    }
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

    ofSetBackgroundColor(0);
    ofDrawBitmapString("TOP LEFT CORNER", 50, 50);
}

And it always prints OF_ORIENTATION_DEFAULT regardless of the device orientation.
I think this is a bug since this worked properly on of_v0.9.0_ios version. ( I had to change some codes though as there were some bugs https://forum.openframeworks.cc/t/fixed-orientation-issues-on-ios8/20275)

If anyone has a solution to this, please let me know.
I tested this on both of_v0.9.8_ios and the latest nightly build.

Thanks!

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles