Cache the result of SDL_GetNumDisplayModes()

It's not free when using SDL2-compat.
This commit is contained in:
Cameron Gutman committed 2026-03-28 21:57:51 -05:00
1 parent 89c8462e9e
commit 91ce7a41e5
2 files changed
+6 -3

No files matched your search

+2 -1
View File
@@ -244,7 +244,8 @@ void SystemProperties::refreshDisplays()
// Start at desktop mode and work our way up
bestMode = desktopMode;
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
int numDisplayModes = SDL_GetNumDisplayModes(displayIndex);
for (int i = 0; i < numDisplayModes; i++) {
SDL_DisplayMode mode;
if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) {
if (mode.w == desktopMode.w && mode.h == desktopMode.h) {