Cache the result of SDL_GetNumDisplayModes()

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

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) {