Closed dudejj closed 1 month ago
vab
can not do much about the problem you describe since handling device orientation on Android can be handled in many ways. sokol_app
(the app "shell" that gg
uses) seem to use ANativeWindow_getWidth()
and ANativeWindow_getHeight()
for reporting screen width/height (and does not seem to account any orientation) (https://github.com/floooh/sokol/blob/1eb96dd0f96b9ea73065f9078244c2255c2b75d9/sokol_app.h#L8218). Other app shells may implement it differently by e.g. listening for orientation change events in the Java activity (which recent versions of SDL does) - some apps do not handle it at all and rely on values in AndroidManifest.xml
.
You can use your own AndroidManifest.xml
and your own Java "main" activity with vab
by passing in a custom override directory via the --package-overrides
flag. That makes it possible to provide custom functionality (like handling device orientation changes) from Java to V via e.g. JNI. (I happen to maintain a JNI wrapper for V here: https://github.com/larpon/jni).
Whether or not your problem is a bug, misconfiguration or other issue is hard to say. vab
's default AndroidManifest.xml
is configured so it is possible to run as many as V's graphical examples as possible out of the box - but does not go further in handling e.g. orientation - that is left to the programmer of the specific app to do.
If I compile for example 2048.v to android, run it and change the orientation of the device, app's scaling goes too small, too big or whatever in between.
I guess the reason is that in orientation change both the code and the device is resizing and it don't end well.
If I remove orientation activity from AndroidManifest.xml (a hint from some android chat), scale stays but at least this 2048 restarts in orientation change. Not a good feature for a game.
In my own graphical app testing, the issue is same. If I try to get screen size with gg.screen_size() to handle window size/scaling by code to screen limits, it returns zeroes and can not be done. Context.window_size() (and gg.window_size() ) gives different values after orientation changes (even when back to same orientation). Is there a way to handle this by vab or is it purely gg and coding issue.