更改现有 window 的 SDL_WINDOW_RESIZABLE

Changing SDL_WINDOW_RESIZABLE of an existing window

我正在尝试使用 SDL_SetWindowResizable 在运行时更改 SDL_WINDOW_RESIZABLE 标志的值。但是 window 并没有改变它的行为。

我想让我的应用程序 (Android) 响应自动旋转设置的变化,目前我能做到的唯一方法是销毁 window 并在 RESIZABLE 标志上使用适当的值重新创建它。 但似乎有点太多了,有没有办法改变设置并强制改变行为而不必重新创建它?

[编辑:] 我测试了更多......如果我在 SDL_SetWindowResizable.

之前和之后阅读标志
SDL_SetWindowResizable, there's no change at all... 
if (os_android_isOrientationEnabled()) {
    SDL_SetWindowResizable(gWindow, SDL_TRUE);
    uint32_t flgs=SDL_GetWindowFlags(gWindow);
    __android_log_print(ANDROID_LOG_DEBUG,"TXT", "Debug %08x" ,(flgs&SDL_WINDOW_RESIZABLE));
    }
else {
    SDL_SetWindowResizable(gWindow, SDL_FALSE);
    uint32_t flgs=SDL_GetWindowFlags(gWindow);
    __android_log_print(ANDROID_LOG_DEBUG,"TXT", "Debug %08x" ,(flgs&SDL_WINDOW_RESIZABLE));
}

一直都是同样的结果。

2022-03-22 10:46:26.559 29164-29247/com.example.texturerender D/TXT: Debug 00000020
2022-03-22 10:47:03.464 29164-29247/com.example.texturerender D/TXT: Debug 00000020

无论是否将 RESIZABLE 设置为 true 或 false...

在进行可调整大小之前,我什至尝试将全屏设置为 0,因为文档中指出它无法在全屏中工作 window。

if (os_android_isOrientationEnabled()) {
    SDL_SetWindowFullscreen(gWindow,0);
    SDL_SetWindowResizable(gWindow, SDL_TRUE);
    SDL_SetWindowFullscreen(gWindow,SDL_WINDOW_FULLSCREEN_DESKTOP);
    uint32_t flgs=SDL_GetWindowFlags(gWindow);
    __android_log_print(ANDROID_LOG_DEBUG,"TXT", "Debug %08x" ,(flgs&SDL_WINDOW_RESIZABLE));
}
else {
    SDL_SetWindowFullscreen(gWindow,0);
    SDL_SetWindowResizable(gWindow, SDL_FALSE);
    SDL_SetWindowFullscreen(gWindow,SDL_WINDOW_FULLSCREEN_DESKTOP);
    uint32_t flgs=SDL_GetWindowFlags(gWindow);
    __android_log_print(ANDROID_LOG_DEBUG,"TXT", "Debug %08x" ,(flgs&SDL_WINDOW_RESIZABLE));
}

这对 Android 不起作用,还是我遗漏了什么?

刚刚发布了修复 SDL_SetWindowResizable Android 的补丁:https://github.com/libsdl-org/SDL/commit/f5a980448ed3a525a68cd844e37f9384c21e7e8e

在更改可调整大小标志之前,必须将全屏设置为 0。