[Scummvm-git-logs] scummvm master -> 4f8962bff9bf1c18e57435b7324f4e8076e74014

ccawley2011 noreply at scummvm.org
Fri Aug 26 20:47:15 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4f8962bff9 OPENGL3D: Restore support for aspect ratio correction


Commit: 4f8962bff9bf1c18e57435b7324f4e8076e74014
    https://github.com/scummvm/scummvm/commit/4f8962bff9bf1c18e57435b7324f4e8076e74014
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-08-26T21:47:11+01:00

Commit Message:
OPENGL3D: Restore support for aspect ratio correction

Changed paths:
    backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
    backends/graphics3d/openglsdl/openglsdl-graphics3d.h


diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
index 89e5f30cbb6..0c7706c3fb6 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
@@ -55,6 +55,7 @@ OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSour
 	_overlayScreen(nullptr),
 	_overlayBackground(nullptr),
 	_fullscreen(false),
+	_lockAspectRatio(true),
 	_stretchMode(STRETCH_FIT),
 	_frameBuffer(nullptr),
 	_surfaceRenderer(nullptr),
@@ -156,6 +157,7 @@ bool OpenGLSdlGraphics3dManager::hasFeature(OSystem::Feature f) const {
 		(f == OSystem::kFeatureFullscreenToggleKeepsContext) ||
 #endif
 		(f == OSystem::kFeatureVSync) ||
+		(f == OSystem::kFeatureAspectRatioCorrection) ||
 		(f == OSystem::kFeatureStretchMode) ||
 		(f == OSystem::kFeatureOverlaySupportsAlpha && _overlayFormat.aBits() > 3);
 }
@@ -166,6 +168,8 @@ bool OpenGLSdlGraphics3dManager::getFeatureState(OSystem::Feature f) const {
 			return isVSyncEnabled();
 		case OSystem::kFeatureFullscreenMode:
 			return _fullscreen;
+		case OSystem::kFeatureAspectRatioCorrection:
+			return _lockAspectRatio;
 		default:
 			return false;
 	}
@@ -180,6 +184,9 @@ void OpenGLSdlGraphics3dManager::setFeatureState(OSystem::Feature f, bool enable
 					createOrUpdateScreen();
 			}
 			break;
+		case OSystem::kFeatureAspectRatioCorrection:
+			_lockAspectRatio = enable;
+			break;
 		default:
 			break;
 	}
@@ -430,6 +437,20 @@ void OpenGLSdlGraphics3dManager::handleResizeImpl(const int width, const int hei
 	_screenChangeCount++;
 }
 
+bool OpenGLSdlGraphics3dManager::gameNeedsAspectRatioCorrection() const {
+	if (_lockAspectRatio) {
+		const uint width = getWidth();
+		const uint height = getHeight();
+
+		// In case we enable aspect ratio correction we force a 4/3 ratio.
+		// But just for 320x200 and 640x400 games, since other games do not need
+		// this.
+		return (width == 320 && height == 200) || (width == 640 && height == 400);
+	}
+
+	return false;
+}
+
 void OpenGLSdlGraphics3dManager::initializeOpenGLContext() const {
 	OpenGLContext.initialize(_glContextType);
 
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
index 59af7fe0f69..e6296516ff9 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
@@ -110,7 +110,7 @@ public:
 	void notifyVideoExpose() override {};
 	void notifyResize(const int width, const int height) override;
 
-	bool gameNeedsAspectRatioCorrection() const override { return false; }
+	bool gameNeedsAspectRatioCorrection() const override;
 
 	bool notifyMousePosition(Common::Point &mouse) override;
 
@@ -159,6 +159,7 @@ protected:
 	int _stretchMode;
 	bool _vsync;
 	bool _fullscreen;
+	bool _lockAspectRatio;
 
 	OpenGL::TiledSurface *_overlayScreen;
 	OpenGL::TiledSurface *_overlayBackground;




More information about the Scummvm-git-logs mailing list