SDL: Set better default scaler for high-resolution games

Now that we have higher scale factors than 3, it makes sense to try and
figure out a default scaler for high-resolution games that approximate
the window size of a low resolution game.

That also means that we are not necessarily restricted to the normal
scaler, since AdvMame has both 2x and 4x versions.
This commit is contained in:
Torbjörn Andersson 2021-08-26 20:14:32 +02:00 committed by Eugene Sandulenko
parent dcf4fb5d2d
commit b5f27b5950

View File

@ -716,12 +716,20 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo
if ((int)w != _videoMode.screenWidth || (int)h != _videoMode.screenHeight) {
const bool useDefault = defaultGraphicsModeConfig();
int scaleFactor = ConfMan.getInt("scale_factor");
int mode = _videoMode.scalerIndex;
if (useDefault && w > 320) {
// Only the normal scaler has a 1x mode
setScaler(ScalerMan.findScalerPluginIndex("normal"), 1);
} else {
setScaler(_videoMode.scalerIndex, ConfMan.getInt("scale_factor"));
// The default scaler is assumed to be for low
// resolution games. For high resolution games, pick
// the largest scale factor that gives at most the
// same window width.
scaleFactor = MAX<uint>(1, (scaleFactor * 320) / w);
// Only the normal scaler has a 1x mode.
if (scaleFactor == 1)
mode = ScalerMan.findScalerPluginIndex("normal");
}
setScaler(mode, scaleFactor);
}
_videoMode.screenWidth = w;