1

I have got a problem handling orientation changes from a nativeactivity for my opengl related app.

I have the JNI setup for two functions:
- One for setting the orientation and
- One for getting what the orientation currently is.

I am using the constants for setRequestedOrientation(int):

6 is SENSOR_LANDSCAPE, 
7 is SENSOR_PORTRAIT,  
4 is just SENSOR.

Now, im using config changes to handle it myself. And in this function I'm calling the java getorientation() function i setup. It is reporting correctly either landscape or portrait.

The problem comes in when i go to initialize my EGL display again. ANativeWindow_getWidth(window) is not reporting the correct width at all times. It'll work half the time. I think the engine->app->window is something being set from the parameter in android_main() and is used by egl to determine the screen dimensions.

But the value is wrong because i dont know how you go about updating the window with the correct one via config changes. anyone have any idea what i can do?

Heyji
  • 1,113
  • 8
  • 26
cyb3rcolby
  • 53
  • 7
  • I have the same problem. Interestingly, when I rotate the phone back again, getting the orientation gets the previously-rotated orientation -- it's as if the system hasn't yet updated its idea of what the new orientation is when I get the notification. (I re-create the surface and then ask it for its size.) – Jon Watte Nov 01 '20 at 04:59

0 Answers0