[rcore][Android] Allow setting window size on Android. - #5810
Conversation
|
@Bigfoot71 since you have more experience with Android, please, could you take a quick look to this PR? |
|
@raysan5 I'm not aware of the problem described, I'd have to dust off raymob and test that (I will do it soon, given the release of 6.0). But as it stands, it seems a bit tricky to me. I will give better feedback as soon as I can. |
|
It'd be great if you could test for 6.0 - I was testing this using raylib-go which is still on the last released 5.x version :) Also: sorry for updating after 4 days - I don't have the GitHub app or GH notification emails enabled, so I only see notifications when I next come onto the website lol |
|
@Bigfoot71 @raysan5 Hey guys, any updates? 😁 |
|
@Bigfoot71 any update on this issue? |
|
I'm not an expert in android but the As I understand in this case the What you described sounds like a racing condition for not using the proper event. |
|
Oh interesting! I believe I did try |
|
Before I test, is this really the best way to resize the raylib "window"/screen? CORE.Window.display.width = width;
CORE.Window.display.height = height;
SetupViewport(width, height);
CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height;
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;(where I only ask because that's a lot of different variables ( |
My situation
APP_CMD_CONFIG_CHANGED.Why not just add this in
AndroidCommandCallback'sAPP_CMD_CONFIG_CHANGEDcase?Android does not send the correct width and height in time, therefore leading to you having to manually switch the height and width. This is fine, until you notice that Android has a somewhat-common chance to send the correct width and height and then everything gets stretched because you swapped the width to be the height to account for the wrong timing.
You could make a variable to mark the window as dirty then in a place that is triggered every frame, if that variable is true and the Android-reported size != current window size, set the variable to false and then update to the new size.
The solution for devs using raylib
SetWindowSizeto be usable, via this patch, on android.SetWindowSize(int width, int height).Additional comments
Let me know if this is okay - personally I wouldn't accept this PR as I'm sure there is a solution that allows putting this code in
APP_CMD_CONFIG_CHANGEDwhile receiving correct sizes from Android (see my 'Why not ...' above for why we can't do this already).This also is a better solution as it also correctly sets the size when INIT_WINDOW happens. So, if the app is in landscape and the users turns off the phone screen then turns it back on with the orientation in portrait, then that is also handled as the size change is detected.
Demos
Fix from this PR:
fixed.by.this.pr.mp4
Default behaviour:
app.stretch.mp4