Landscape issue on Android

I have a casual issue about the landscape mode on Android. I can not make my app running in landscape mode. The issue is not general as I can run the standard examples in landscape mode with no problem.

Whenever I run my game, I can not run it in the landscape mode. In the end of the first cycle of draw() loop, it turns itself to the portrait mode. (I use OF as a shared library included to my project.)

my draw method is like that:

void testApp::draw() {
    ofLogNotice("testApp.cpp") << "DRAW STARTED";
    ofLogNotice("testApp.cpp") << "o1:" << ofGetOrientation() << ", w:" << ofGetWidth() << ", h:" << ofGetHeight();
    camera.begin(ofGetCurrentViewport());
    ofLogNotice("testApp.cpp") << "o2:" << ofGetOrientation() << ", w:" << ofGetWidth() << ", h:" << ofGetHeight();
    assimpmodel1.drawFaces();
    ofLogNotice("testApp.cpp") << "o3:" << ofGetOrientation() << ", w:" << ofGetWidth() << ", h:" << ofGetHeight();
    assimpmodel2.drawFaces();
    ofLogNotice("testApp.cpp") << "o4:" << ofGetOrientation() << ", w:" << ofGetWidth() << ", h:" << ofGetHeight();
    camera.end();
    ofLogNotice("testApp.cpp") << "o5:" << ofGetOrientation() << ", w:" << ofGetWidth() << ", h:" << ofGetHeight();
    drawGUI();
    ofLogNotice("testApp.cpp") << "o6:" << ofGetOrientation() << ", w:" << ofGetWidth() << ", h:" << ofGetHeight();
    ofLogNotice("testApp.cpp") << "DRAW FINISHED";
}

And the logs are like that:

TESTAPP SETUP STARTED
TESTAPP SETUP FINISHED
UPDATE STARTED
UPDATE FINISHED
DRAW STARTED
o1:1, w:480, h:270
o2:1, w:480, h:270
eglSurfaceAttrib not implemented //THIS WARNING IS ONLY IN LANDSCAPE MODE
o3:1, w:480, h:270
o4:1, w:480, h:270
o5:1, w:480, h:270
o6:1, w:480, h:270
DRAW FINISHED
resize 320x430 //THIS AUTO-RESIZE IS ONLY IN LANDSCAPE MODE
TESTAPP WINDOW RESIZED
UPDATE STARTED
UPDATE FINISHED
DRAW STARTED
o1:1, w:320, h:430
o2:1, w:320, h:430
o3:1, w:320, h:430
o4:1, w:320, h:430
o5:1, w:320, h:430
o6:1, w:320, h:430
DRAW FINISHED
UPDATE STARTED
UPDATE FINISHED
DRAW STARTED
o1:1, w:320, h:430
o2:1, w:320, h:430
o3:1, w:320, h:430
o4:1, w:320, h:430
o5:1, w:320, h:430
o6:1, w:320, h:430
DRAW FINISHED
UPDATE STARTED
UPDATE FINISHED
DRAW STARTED
o1:1, w:320, h:430
o2:1, w:320, h:430
o3:1, w:320, h:430
... then continue same...

The “eglSurfaceAttrib not implemented” warning does only happen when I try to run in landscape mode, then the game resize its screen to the portrait mode.

I tried;

  • to add OFAndroid.setScreenOrientation(90); in Java side but no success
  • to delete/change ofSetupOpenGL(320, 430, OF_WINDOW); in main.cpp but no success

Do you have any idea about what I have to do?

how are you changing the orientation? usually ofSetOrientation(OF_ORIENTATION_90) should do

also you can fix the orientation in the android manifest

It is “landscape” in the Android manifest.

The app starts and stay in landscape mode during the grey screen. Then it turns to portrait mode when it comes to draw().

I am going to try ofSetOrientation(OF_ORIENTATION_90) now.

mmh it might be a bug in OF trying to set a default orientation. are you using 0.8 or latest master? i remember fixing something along this lines some time ago but not sure

I use 0.8.0

I try now the original examples but I get INSTALL_FAILED_CONTAINER_ERROR and I can not run them :slight_smile:

This one is not an OF bug, but a sdcard problem. I will work on my original problem after solving this new one.

I go crazy :slight_smile:

ofSetOrientation(OF_ORIENTATION_90_LEFT); solved the problem. Thanks.