WIP SDL3 compatibility

This commit is contained in:
Cameron Gutman
2025-01-31 01:13:17 -06:00
parent 5290305944
commit 231a67946d
34 changed files with 772 additions and 497 deletions
+11 -6
View File
@@ -197,15 +197,18 @@ void SystemProperties::refreshDisplaysInternal()
monitorNativeResolutions.clear();
int numDisplays = 0;
SDL_DisplayID *displays = SDL_GetDisplays(&numDisplays);
SDL_DisplayMode bestMode;
for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) {
for (int i = 0; i < numDisplays; i++) {
SDL_DisplayMode desktopMode;
SDL_Rect safeArea;
if (StreamUtils::getNativeDesktopMode(displayIndex, &desktopMode, &safeArea)) {
if (StreamUtils::getNativeDesktopMode(displays[i], &desktopMode, &safeArea)) {
if (desktopMode.w <= 8192 && desktopMode.h <= 8192) {
monitorNativeResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
monitorSafeAreaResolutions.insert(displayIndex, QRect(0, 0, safeArea.w, safeArea.h));
monitorNativeResolutions.insert(i, QRect(0, 0, desktopMode.w, desktopMode.h));
monitorSafeAreaResolutions.insert(i, QRect(0, 0, safeArea.w, safeArea.h));
}
else {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
@@ -215,9 +218,10 @@ void SystemProperties::refreshDisplaysInternal()
// Start at desktop mode and work our way up
bestMode = desktopMode;
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
int numDisplayModes = SDL_GetNumDisplayModes(displays[i]);
for (int i = 0; i < numDisplayModes; i++) {
SDL_DisplayMode mode;
if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) {
if (SDL_GetDisplayMode(displays[i], i, &mode) == 0) {
if (mode.w == desktopMode.w && mode.h == desktopMode.h) {
if (mode.refresh_rate > bestMode.refresh_rate) {
bestMode = mode;
@@ -240,5 +244,6 @@ void SystemProperties::refreshDisplaysInternal()
}
}
SDL_free(displays);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}