[Scummvm-git-logs] scummvm master -> 59ba9cb71520cc9f58fbe9b72c6a661fff5a372f

aquadran aquadran at gmail.com
Tue Oct 13 18:28:02 UTC 2020


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:
59ba9cb715 SDL: Do not allow toggle fullscreen for backends which can lose opengl context used for 3d games. (#2514)


Commit: 59ba9cb71520cc9f58fbe9b72c6a661fff5a372f
    https://github.com/scummvm/scummvm/commit/59ba9cb71520cc9f58fbe9b72c6a661fff5a372f
Author: Paweł Kołodziejski (aquadran at users.sourceforge.net)
Date: 2020-10-13T20:27:58+02:00

Commit Message:
SDL: Do not allow toggle fullscreen for backends which can lose opengl context used for 3d games. (#2514)

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
    backends/graphics3d/sdl/sdl-graphics3d.cpp
    backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp
    common/system.h


diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 49ee47ab83..d4063a2199 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -94,6 +94,9 @@ bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) const {
 	case OSystem::kFeatureAspectRatioCorrection:
 	case OSystem::kFeatureCursorPalette:
 	case OSystem::kFeatureFilteringMode:
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+	case OSystem::kFeatureFullscreenToggleKeepsContext:
+#endif
 	case OSystem::kFeatureStretchMode:
 		return true;
 
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index b4857989f7..fa20f647f5 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -205,6 +205,9 @@ bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) const {
 	switch (f) {
 	case OSystem::kFeatureFullscreenMode:
 	case OSystem::kFeatureIconifyWindow:
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+	case OSystem::kFeatureFullscreenToggleKeepsContext:
+#endif
 		return true;
 
 	default:
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index d5e766a690..38cf0dea7e 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -348,8 +348,10 @@ bool SdlGraphicsManager::notifyEvent(const Common::Event &event) {
 }
 
 void SdlGraphicsManager::toggleFullScreen() {
-	if (!g_system->hasFeature(OSystem::kFeatureFullscreenMode))
+	if (!g_system->hasFeature(OSystem::kFeatureFullscreenMode) ||
+	   (!g_system->hasFeature(OSystem::kFeatureFullscreenToggleKeepsContext) && g_system->hasFeature(OSystem::kFeatureOpenGLForGame))) {
 		return;
+	}
 
 	beginGFXTransaction();
 	setFeatureState(OSystem::kFeatureFullscreenMode, !getFeatureState(OSystem::kFeatureFullscreenMode));
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index ad2a5d1488..746f801ab0 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -222,6 +222,7 @@ bool SurfaceSdlGraphicsManager::hasFeature(OSystem::Feature f) const {
 		(f == OSystem::kFeatureAspectRatioCorrection) ||
 		(f == OSystem::kFeatureFilteringMode) ||
 #if SDL_VERSION_ATLEAST(2, 0, 0)
+		(f == OSystem::kFeatureFullscreenToggleKeepsContext) ||
 		(f == OSystem::kFeatureStretchMode) ||
 #endif
 		(f == OSystem::kFeatureCursorPalette) ||
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
index c21f94e6ec..39114c162b 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
@@ -78,7 +78,7 @@ OpenGLSdlGraphics3dManager::~OpenGLSdlGraphics3dManager() {
 bool OpenGLSdlGraphics3dManager::hasFeature(OSystem::Feature f) const {
 	return
 		(f == OSystem::kFeatureFullscreenMode) ||
-		(f == OSystem::kFeatureOpenGL) ||
+		(f == OSystem::kFeatureOpenGLForGame) ||
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 		(f == OSystem::kFeatureFullscreenToggleKeepsContext) ||
 #endif
diff --git a/backends/graphics3d/sdl/sdl-graphics3d.cpp b/backends/graphics3d/sdl/sdl-graphics3d.cpp
index c3a3284ac0..c66340b794 100644
--- a/backends/graphics3d/sdl/sdl-graphics3d.cpp
+++ b/backends/graphics3d/sdl/sdl-graphics3d.cpp
@@ -123,8 +123,10 @@ bool SdlGraphics3dManager::notifyEvent(const Common::Event &event) {
 }
 
 void SdlGraphics3dManager::toggleFullScreen() {
-	if (!g_system->hasFeature(OSystem::kFeatureFullscreenMode))
+	if (!g_system->hasFeature(OSystem::kFeatureFullscreenMode) ||
+	   (!g_system->hasFeature(OSystem::kFeatureFullscreenToggleKeepsContext) && g_system->hasFeature(OSystem::kFeatureOpenGLForGame))) {
 		return;
+	}
 
 	setFeatureState(OSystem::kFeatureFullscreenMode, !getFeatureState(OSystem::kFeatureFullscreenMode));
 }
diff --git a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp
index 1f752eba2e..d9db46a199 100644
--- a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp
+++ b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp
@@ -76,9 +76,7 @@ SurfaceSdlGraphics3dManager::~SurfaceSdlGraphics3dManager() {
 
 bool SurfaceSdlGraphics3dManager::hasFeature(OSystem::Feature f) const {
 	return
-#if SDL_VERSION_ATLEAST(2, 0, 0)
 		(f == OSystem::kFeatureFullscreenToggleKeepsContext) ||
-#endif
 		(f == OSystem::kFeatureAspectRatioCorrection) ||
 		(f == OSystem::kFeatureFullscreenMode);
 }
diff --git a/common/system.h b/common/system.h
index cee39bcd86..a5c38be17f 100644
--- a/common/system.h
+++ b/common/system.h
@@ -375,9 +375,9 @@ public:
 
 		/**
 		 * This feature flag can be used to check if hardware accelerated
-		 * OpenGl is supported.
+		 * OpenGL is supported and can be used for 3D game rendering.
 		 */
-		kFeatureOpenGL,
+		kFeatureOpenGLForGame,
 
 		/**
 		 * If supported, this feature flag can be used to check if




More information about the Scummvm-git-logs mailing list