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

This commit is contained in:
Paweł Kołodziejski 2020-10-13 20:27:58 +02:00 committed by GitHub
parent 495eb1b370
commit 59ba9cb715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 7 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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));

View File

@ -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) ||

View File

@ -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

View File

@ -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));
}

View File

@ -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);
}

View File

@ -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