aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/surfacesdl/surfacesdl-graphics.cpp1
-rw-r--r--backends/graphics/windowed.h12
2 files changed, 11 insertions, 2 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index e14471b067..f71aa20865 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -76,6 +76,7 @@ const OSystem::GraphicsMode s_supportedStretchModes[] = {
{"pixel-perfect", _s("Pixel-perfect scaling"), STRETCH_INTEGRAL},
{"fit", _s("Fit to window"), STRETCH_FIT},
{"stretch", _s("Stretch to window"), STRETCH_STRETCH},
+ {"fit_force_aspect", _s("Fit to window (4:3)"), STRETCH_FIT_FORCE_ASPECT},
{nullptr, nullptr, 0}
};
#endif
diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h
index b725ca08b4..66b1476d22 100644
--- a/backends/graphics/windowed.h
+++ b/backends/graphics/windowed.h
@@ -34,7 +34,8 @@ enum {
STRETCH_CENTER = 0,
STRETCH_INTEGRAL = 1,
STRETCH_FIT = 2,
- STRETCH_STRETCH = 3
+ STRETCH_STRETCH = 3,
+ STRETCH_FIT_FORCE_ASPECT = 4
};
class WindowedGraphicsManager : virtual public GraphicsManager {
@@ -341,6 +342,7 @@ private:
// Mode Integral = scale by an integral amount.
// Mode Fit = scale to fit the window while respecting the aspect ratio
// Mode Stretch = scale and stretch to fit the window without respecting the aspect ratio
+ // Mode Fit Force Aspect = scale to fit the window while forcing a 4:3 aspect ratio
int width = 0, height = 0;
if (mode == STRETCH_CENTER || mode == STRETCH_INTEGRAL) {
@@ -359,7 +361,13 @@ private:
frac_t windowAspect = intToFrac(_windowWidth) / _windowHeight;
width = _windowWidth;
height = _windowHeight;
- if (mode != STRETCH_STRETCH) {
+ if (mode == STRETCH_FIT_FORCE_ASPECT) {
+ frac_t ratio = intToFrac(4) / 3;
+ if (windowAspect < ratio)
+ height = intToFrac(width) / ratio;
+ else if (windowAspect > ratio)
+ width = fracToInt(height * ratio);
+ } else if (mode != STRETCH_STRETCH) {
if (windowAspect < displayAspect)
height = intToFrac(width) / displayAspect;
else if (windowAspect > displayAspect)