libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.24k stars 1.87k forks source link

Android: window does not stretch to fit #9281

Open katemonster33 opened 8 months ago

katemonster33 commented 8 months ago

Hi,

I work on the game Cataclysm: Dark Days Ahead. We target several platforms, including Android. We were using an ancient version of SDL (v2.0.12) until recently, when I updated to v2.30.0 here ( https://github.com/CleverRaven/Cataclysm-DDA/commit/ccc011810f16429ef8dd6f6734ada041ada39691 ) and ever since, the window shows small - we draw in a lower resolution based on user settings, then rely on SDL to stretch the window to fit - after v2.30 0, suddenly the window does not stretch, it remains small, and users are forced to check this "forced full screen" check box which hides the back button - not desired. Anything obvious we may have missed? We have some small patches for SDL that you can see here ( https://github.com/katemonster33/SDL ) but it doesn't look like anything that should affect this.

slouken commented 8 months ago

Are you using the SDL render API? If so, are you using SDL_RenderSetLogicalSize()?

katemonster33 commented 8 months ago

Are you using the SDL render API? If so, are you using SDL_RenderSetLogicalSize()?

Yes, the SDL window is created with a specified resolution (don't remember what exactly) with flags of "resizable" and "allow high DPI" (on phone, can't remember exactly). Then the renderer is setup with RenderSetLogicalSize with the same resolution passed to the window.

Right now the work around is to tell users to check this "forced full screen" box in our settings that modifies the SDL window to add full screen to the flags. this works but like I said, the nav bar becomes hidden and needs to be recalled by swiping from the side of the screen. We want the window to fill the screen, but we need the nav bar to always be shown because we trap the back button and handle it specially in the application.

katemonster33 commented 8 months ago

I see you added a release milestone, are you thinking this is an SDL issue? Any possible work-arounds?

slouken commented 8 months ago

I don't know, I haven't had a chance to look. It's supposed to work the way you'd expect - create a window, set a logical size, then SDL will handle stretching it into position. I'm not sure why it's not working for you. Are you able to reproduce this with the SDL test programs?

katemonster33 commented 8 months ago

Thanks for the message. I've got some time tonight to try a few things, I'll try that among other things and report back.

katemonster33 commented 8 months ago

I added SDL_WINDOW_MAXIMIZED to the window flags and removed SDL_WINDOW_RESIZABLE and that seems to have fixed it. Only other flag we have is SDL_WINDOW_ALLOW_HIGH_DPI

katemonster33 commented 8 months ago

Just to be clear - these flags were not changed with the SDL version update