When entering exclusive fullscreen, SDL3 verifies that the requested mode parameters precisely match a mode exposed by the output, which can cause the mode switch to fail due to the float to int rounding of the refresh rate when converting between the SDL2 and SDL3 mode structs. Instead of casting directly, use the SDL2 mode parameters to try and find the closest matching SDL3 display mode.
This fixes video mode switching for modes with refresh rates that are not precisely an integer, and allows for the removal of the DisplayMode_2to3() function entirely.
Tested to fix both the SDL test suite (testsprite2 with ctrl+enter), and real-world cases such as changing the resolution in vkQuake on displays with refresh rates that are not an exact integer value.
When entering exclusive fullscreen, SDL3 verifies that the requested mode parameters precisely match a mode exposed by the output, which can cause the mode switch to fail due to the float to int rounding of the refresh rate when converting between the SDL2 and SDL3 mode structs. Instead of casting directly, use the SDL2 mode parameters to try and find the closest matching SDL3 display mode.
This fixes video mode switching for modes with refresh rates that are not precisely an integer, and allows for the removal of the DisplayMode_2to3() function entirely.
Tested to fix both the SDL test suite (testsprite2 with ctrl+enter), and real-world cases such as changing the resolution in vkQuake on displays with refresh rates that are not an exact integer value.