[Scummvm-git-logs] scummvm master -> 40f797fdef159d158a9e3b1b249c36251c596a0d
sev-
noreply at scummvm.org
Mon Jan 16 17:09:58 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
138a983d80 COMMON: Refactor VSync handling to match the other options
40f797fdef SDL: Support VSync with OpenGL in SDL1 builds
Commit: 138a983d803dd64d9beeeabd65cfa5194dee8299
https://github.com/scummvm/scummvm/commit/138a983d803dd64d9beeeabd65cfa5194dee8299
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-01-16T18:09:53+01:00
Commit Message:
COMMON: Refactor VSync handling to match the other options
Changed paths:
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/sdl/sdl-graphics.cpp
backends/graphics/sdl/sdl-graphics.h
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
backends/graphics3d/openglsdl/openglsdl-graphics3d.h
base/main.cpp
common/system.h
engines/ags/engine/gfx/ali_3d_scummvm.cpp
engines/engine.cpp
engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
gui/options.cpp
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index d18c7a3a1f9..b2dc3d9735e 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -134,6 +134,10 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource,
_glContextType = OpenGL::kContextGL;
#endif
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ _vsync = ConfMan.getBool("vsync");
+#endif
+
// Retrieve a list of working fullscreen modes
Common::Rect desktopRes = _window->getDesktopResolution();
#if SDL_VERSION_ATLEAST(2, 0, 0)
@@ -213,6 +217,13 @@ void OpenGLSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
_wantsFullScreen = enable;
break;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ case OSystem::kFeatureVSync:
+ assert(getTransactionMode() != kTransactionNone);
+ _vsync = enable;
+ break;
+#endif
+
case OSystem::kFeatureIconifyWindow:
if (enable) {
_window->iconifyWindow();
@@ -242,7 +253,7 @@ bool OpenGLSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
case OSystem::kFeatureVSync:
- return SDL_GL_GetSwapInterval() != 0;
+ return _vsync;
#endif
default:
@@ -530,7 +541,6 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
return false;
}
- _vsync = ConfMan.getBool("vsync");
if (SDL_GL_SetSwapInterval(_vsync ? 1 : 0)) {
warning("Unable to %s VSync: %s", _vsync ? "enable" : "disable", SDL_GetError());
}
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 4d57559b36e..10fca20daf9 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -69,6 +69,7 @@ SdlGraphicsManager::State SdlGraphicsManager::getState() const {
state.aspectRatio = getFeatureState(OSystem::kFeatureAspectRatioCorrection);
state.fullscreen = getFeatureState(OSystem::kFeatureFullscreenMode);
state.cursorPalette = getFeatureState(OSystem::kFeatureCursorPalette);
+ state.vsync = getFeatureState(OSystem::kFeatureVSync);
#ifdef USE_RGB_COLOR
state.pixelFormat = getScreenFormat();
#endif
@@ -93,6 +94,7 @@ bool SdlGraphicsManager::setState(const State &state) {
setFeatureState(OSystem::kFeatureAspectRatioCorrection, state.aspectRatio);
setFeatureState(OSystem::kFeatureFullscreenMode, state.fullscreen);
setFeatureState(OSystem::kFeatureCursorPalette, state.cursorPalette);
+ setFeatureState(OSystem::kFeatureVSync, state.vsync);
if (endGFXTransaction() != OSystem::kTransactionSuccess) {
return false;
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index 10e2bd3b61b..a391bc59fad 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -109,6 +109,7 @@ public:
bool aspectRatio;
bool fullscreen;
bool cursorPalette;
+ bool vsync;
#ifdef USE_RGB_COLOR
Graphics::PixelFormat pixelFormat;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 7f8ae07cfe1..50d1f43caf0 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -114,7 +114,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
_osdIconSurface(nullptr),
#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
- _renderer(nullptr), _screenTexture(nullptr), _vsync(false),
+ _renderer(nullptr), _screenTexture(nullptr),
#endif
#if defined(WIN32) && !SDL_VERSION_ATLEAST(2, 0, 0)
_originalBitsPerPixel(0),
@@ -180,6 +180,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
_videoMode.filtering = ConfMan.getBool("filtering");
#if SDL_VERSION_ATLEAST(2, 0, 0)
_videoMode.stretchMode = STRETCH_FIT;
+ _videoMode.vsync = ConfMan.getBool("vsync");
#endif
_videoMode.scalerIndex = getDefaultScaler();
@@ -236,6 +237,11 @@ void SurfaceSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
case OSystem::kFeatureFilteringMode:
setFilteringMode(enable);
break;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ case OSystem::kFeatureVSync:
+ setVSync(enable);
+ break;
+#endif
case OSystem::kFeatureCursorPalette:
_cursorPaletteDisabled = !enable;
blitCursor();
@@ -264,7 +270,7 @@ bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
#endif
#if SDL_VERSION_ATLEAST(2, 0, 0)
case OSystem::kFeatureVSync:
- return _vsync;
+ return _videoMode.vsync;
#endif
case OSystem::kFeatureFilteringMode:
return _videoMode.filtering;
@@ -343,6 +349,12 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
_videoMode.stretchMode = _oldVideoMode.stretchMode;
}
+
+ if (_videoMode.vsync != _oldVideoMode.vsync) {
+ errors |= OSystem::kTransactionVSyncFailed;
+
+ _videoMode.vsync = _oldVideoMode.vsync;
+ }
#endif
if (_videoMode.filtering != _oldVideoMode.filtering) {
errors |= OSystem::kTransactionFilteringFailed;
@@ -1523,6 +1535,23 @@ void SurfaceSdlGraphicsManager::setFullscreenMode(bool enable) {
}
}
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+void SurfaceSdlGraphicsManager::setVSync(bool enable) {
+ Common::StackLock lock(_graphicsMutex);
+
+ if (!g_system->hasFeature(OSystem::kFeatureVSync))
+ return;
+
+ if (_oldVideoMode.setup && _oldVideoMode.vsync == enable)
+ return;
+
+ if (_transactionMode == kTransactionActive) {
+ _videoMode.vsync = enable;
+ _transactionDetails.needHotswap = true;
+ }
+}
+#endif
+
void SurfaceSdlGraphicsManager::setAspectRatioCorrection(bool enable) {
Common::StackLock lock(_graphicsMutex);
@@ -2627,17 +2656,16 @@ SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height,
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
#endif
- _vsync = ConfMan.getBool("vsync");
- if (_vsync) {
+ if (_videoMode.vsync) {
rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
}
_renderer = SDL_CreateRenderer(_window->getSDLWindow(), -1, rendererFlags);
if (!_renderer) {
- if (_vsync) {
+ if (_videoMode.vsync) {
// VSYNC might not be available, so retry without VSYNC
warning("SDL_SetVideoMode: SDL_CreateRenderer() failed with VSYNC option, retrying without it...");
- _vsync = false;
+ _videoMode.vsync = false;
rendererFlags &= ~SDL_RENDERER_PRESENTVSYNC;
_renderer = SDL_CreateRenderer(_window->getSDLWindow(), -1, rendererFlags);
}
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index b09d709836c..e9ce346945b 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -191,7 +191,6 @@ protected:
int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
- bool _vsync;
#endif
/** Unseen game screen */
@@ -263,6 +262,7 @@ protected:
#if SDL_VERSION_ATLEAST(2, 0, 0)
int stretchMode;
+ bool vsync;
#endif
uint scalerIndex;
@@ -284,6 +284,7 @@ protected:
#if SDL_VERSION_ATLEAST(2, 0, 0)
stretchMode = 0;
+ vsync = false;
#endif
scalerIndex = 0;
@@ -425,6 +426,9 @@ protected:
virtual void setAspectRatioCorrection(bool enable);
void setFilteringMode(bool enable);
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ void setVSync(bool enable);
+#endif
bool saveScreenshot(const Common::String &filename) const override;
virtual void setGraphicsModeIntern();
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
index 573a2b44151..75b1af9c754 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
@@ -140,6 +140,8 @@ OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSour
#else
_glContextType = OpenGL::kContextGL;
#endif
+
+ _vsync = ConfMan.getBool("vsync");
}
OpenGLSdlGraphics3dManager::~OpenGLSdlGraphics3dManager() {
@@ -165,7 +167,7 @@ bool OpenGLSdlGraphics3dManager::hasFeature(OSystem::Feature f) const {
bool OpenGLSdlGraphics3dManager::getFeatureState(OSystem::Feature f) const {
switch (f) {
case OSystem::kFeatureVSync:
- return isVSyncEnabled();
+ return _vsync;
case OSystem::kFeatureFullscreenMode:
return _fullscreen;
case OSystem::kFeatureAspectRatioCorrection:
@@ -184,6 +186,10 @@ void OpenGLSdlGraphics3dManager::setFeatureState(OSystem::Feature f, bool enable
createOrUpdateScreen();
}
break;
+ case OSystem::kFeatureVSync:
+ assert(_transactionMode != kTransactionNone);
+ _vsync = enable;
+ break;
case OSystem::kFeatureAspectRatioCorrection:
_lockAspectRatio = enable;
break;
@@ -291,7 +297,6 @@ void OpenGLSdlGraphics3dManager::setupScreen() {
closeOverlay();
_antialiasing = ConfMan.getInt("antialiasing");
- _vsync = ConfMan.getBool("vsync");
#if SDL_VERSION_ATLEAST(2, 0, 0)
bool needsWindowReset = false;
@@ -598,16 +603,6 @@ bool OpenGLSdlGraphics3dManager::shouldRenderToFramebuffer() const {
return !engineSupportsArbitraryResolutions && _supportsFrameBuffer;
}
-bool OpenGLSdlGraphics3dManager::isVSyncEnabled() const {
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- return SDL_GL_GetSwapInterval() != 0;
-#else
- int swapControl = 0;
- SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swapControl);
- return swapControl != 0;
-#endif
-}
-
void OpenGLSdlGraphics3dManager::drawOverlay() {
_surfaceRenderer->prepareState();
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
index 20e51982e71..d8b19cde173 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.h
@@ -175,8 +175,6 @@ protected:
OpenGL::FrameBuffer *createFramebuffer(uint width, uint height);
bool shouldRenderToFramebuffer() const;
- bool isVSyncEnabled() const;
-
protected:
enum TransactionMode {
diff --git a/base/main.cpp b/base/main.cpp
index e5fc9315541..ff90e557425 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -364,6 +364,7 @@ static void setupGraphics(OSystem &system) {
system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
+ system.setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync"));
system.endGFXTransaction();
system.applyBackendSettings();
diff --git a/common/system.h b/common/system.h
index e2fe5c39080..75ec497bdd5 100644
--- a/common/system.h
+++ b/common/system.h
@@ -993,6 +993,7 @@ public:
kTransactionFilteringFailed = (1 << 5), /**< Failed setting the filtering mode */
kTransactionStretchModeSwitchFailed = (1 << 6), /**< Failed setting the stretch mode */
kTransactionShaderChangeFailed = (1 << 7), /**< Failed setting the shader */
+ kTransactionVSyncFailed = (1 << 8), /**< Failed switching vsync mode */
};
/**
diff --git a/engines/ags/engine/gfx/ali_3d_scummvm.cpp b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
index 75aa9611c0b..6b938985b73 100644
--- a/engines/ags/engine/gfx/ali_3d_scummvm.cpp
+++ b/engines/ags/engine/gfx/ali_3d_scummvm.cpp
@@ -123,8 +123,12 @@ bool ScummVMRendererGraphicsDriver::SetDisplayMode(const DisplayMode &mode) {
const int driver = GFX_SCUMMVM;
if (set_gfx_mode(driver, mode.Width, mode.Height, mode.ColorDepth) != 0)
return false;
- if (g_system->hasFeature(OSystem::kFeatureVSync))
+
+ if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+ g_system->beginGFXTransaction();
g_system->setFeatureState(OSystem::kFeatureVSync, mode.Vsync);
+ g_system->endGFXTransaction();
+ }
OnInit();
OnModeSet(mode);
@@ -222,7 +226,10 @@ bool ScummVMRendererGraphicsDriver::DoesSupportVsyncToggle() {
bool ScummVMRendererGraphicsDriver::SetVsync(bool enabled) {
if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+ g_system->beginGFXTransaction();
g_system->setFeatureState(OSystem::kFeatureVSync, enabled);
+ g_system->endGFXTransaction();
+
_mode.Vsync = g_system->getFeatureState(OSystem::kFeatureVSync);
}
return _mode.Vsync;
diff --git a/engines/engine.cpp b/engines/engine.cpp
index be05b4b3036..d2da357cae5 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -212,6 +212,9 @@ void initCommonGFX() {
if (gameDomain->contains("filtering"))
g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
+ if (gameDomain->contains("vsync"))
+ g_system->setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync"));
+
if (gameDomain->contains("stretch_mode"))
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());
@@ -419,6 +422,7 @@ void initGraphics3d(int width, int height) {
g_system->initSize(width, height);
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); // TODO: Replace this with initCommonGFX()
g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); // TODO: Replace this with initCommonGFX()
+ g_system->setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync")); // TODO: Replace this with initCommonGFX()
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str()); // TODO: Replace this with initCommonGFX()
g_system->endGFXTransaction();
}
diff --git a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
index 034d83f99c8..e9d3306cc6b 100644
--- a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
+++ b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
@@ -277,8 +277,11 @@ void cLowLevelGraphicsSDL::ShowCursor(bool toggle) {
//-----------------------------------------------------------------------
void cLowLevelGraphicsSDL::SetVsyncActive(bool toggle) {
- if (g_system->hasFeature(OSystem::kFeatureVSync))
+ if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+ g_system->beginGFXTransaction();
g_system->setFeatureState(OSystem::kFeatureVSync, toggle);
+ g_system->endGFXTransaction();
+ }
}
//-----------------------------------------------------------------------
diff --git a/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp b/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
index 61c4123fd58..31125b6422d 100644
--- a/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
+++ b/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
@@ -488,8 +488,11 @@ void LowLevelGraphicsTGL::ShowCursor(bool toggle) {
//-----------------------------------------------------------------------
void LowLevelGraphicsTGL::SetVsyncActive(bool toggle) {
- if (g_system->hasFeature(OSystem::kFeatureVSync))
+ if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+ g_system->beginGFXTransaction();
g_system->setFeatureState(OSystem::kFeatureVSync, toggle);
+ g_system->endGFXTransaction();
+ }
}
//-----------------------------------------------------------------------
diff --git a/gui/options.cpp b/gui/options.cpp
index 3105eb0147a..7e81aebbba1 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -425,7 +425,11 @@ void OptionsDialog::build() {
_aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
}
- _vsyncCheckbox->setState(ConfMan.getBool("vsync", _domain));
+ if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+ _vsyncCheckbox->setState(ConfMan.getBool("vsync", _domain));
+ if (ConfMan.isKeyTemporary("vsync"))
+ _vsyncCheckbox->setOverride(true);
+ }
_rendererTypePopUp->setEnabled(true);
_rendererTypePopUp->setSelectedTag(Graphics::Renderer::parseTypeCode(ConfMan.get("renderer", _domain)));
@@ -603,11 +607,15 @@ void OptionsDialog::apply() {
}
if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState())
graphicsModeChanged = true;
- if (ConfMan.getBool("vsync", _domain) != _vsyncCheckbox->getState())
- graphicsModeChanged = true;
+ if (g_system->hasFeature(OSystem::kFeatureVSync)) {
+ if (ConfMan.getBool("vsync", _domain) != _vsyncCheckbox->getState()) {
+ graphicsModeChanged = true;
+ ConfMan.setBool("vsync", _vsyncCheckbox->getState(), _domain);
+ _vsyncCheckbox->setOverride(false);
+ }
+ }
ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain);
- ConfMan.setBool("vsync", _vsyncCheckbox->getState(), _domain);
bool isSet = false;
@@ -763,6 +771,8 @@ void OptionsDialog::apply() {
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen", _domain));
if (ConfMan.hasKey("filtering"))
g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering", _domain));
+ if (ConfMan.hasKey("vsync"))
+ g_system->setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync", _domain));
OSystem::TransactionError gfxError = g_system->endGFXTransaction();
@@ -826,6 +836,12 @@ void OptionsDialog::apply() {
message += _("the filtering setting could not be changed");
}
+ if (gfxError & OSystem::kTransactionVSyncFailed) {
+ ConfMan.setBool("vsync", g_system->getFeatureState(OSystem::kFeatureVSync), _domain);
+ message += Common::U32String("\n");
+ message += _("the vsync setting could not be changed");
+ }
+
if (gfxError & OSystem::kTransactionShaderChangeFailed) {
if (previousShader == _c("None", "shader"))
previousShader = "default";
@@ -1204,7 +1220,6 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
_gfxPopUp->setEnabled(enabled);
_renderModePopUpDesc->setEnabled(enabled);
_renderModePopUp->setEnabled(enabled);
- _vsyncCheckbox->setEnabled(enabled);
_rendererTypePopUpDesc->setEnabled(enabled);
_rendererTypePopUp->setEnabled(enabled);
_antiAliasPopUpDesc->setEnabled(enabled);
@@ -1253,6 +1268,10 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
_aspectCheckbox->setEnabled(false);
else
_aspectCheckbox->setEnabled(enabled);
+
+ if (g_system->hasFeature(OSystem::kFeatureVSync))
+ _vsyncCheckbox->setEnabled(enabled);
+
}
void OptionsDialog::setAudioSettingsState(bool enabled) {
@@ -1585,7 +1604,8 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
// Fullscreen checkbox
_fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", _("Fullscreen mode"), Common::U32String(), kFullscreenToggled);
- _vsyncCheckbox = new CheckboxWidget(boss, prefix + "grVSyncCheckbox", _("V-Sync"), _("Wait for the vertical sync to refresh the screen in order to prevent tearing artifacts"));
+ if (g_system->hasFeature(OSystem::kFeatureVSync))
+ _vsyncCheckbox = new CheckboxWidget(boss, prefix + "grVSyncCheckbox", _("V-Sync"), _("Wait for the vertical sync to refresh the screen in order to prevent tearing artifacts"));
if (g_system->getOverlayWidth() > 320)
_rendererTypePopUpDesc = new StaticTextWidget(boss, prefix + "grRendererTypePopupDesc", _("Game 3D Renderer:"));
Commit: 40f797fdef159d158a9e3b1b249c36251c596a0d
https://github.com/scummvm/scummvm/commit/40f797fdef159d158a9e3b1b249c36251c596a0d
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-01-16T18:09:53+01:00
Commit Message:
SDL: Support VSync with OpenGL in SDL1 builds
Changed paths:
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/openglsdl/openglsdl-graphics.h
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index b2dc3d9735e..ebc1ccc2a82 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -134,9 +134,7 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource,
_glContextType = OpenGL::kContextGL;
#endif
-#if SDL_VERSION_ATLEAST(2, 0, 0)
_vsync = ConfMan.getBool("vsync");
-#endif
// Retrieve a list of working fullscreen modes
Common::Rect desktopRes = _window->getDesktopResolution();
@@ -199,9 +197,9 @@ bool OpenGLSdlGraphicsManager::hasFeature(OSystem::Feature f) const {
switch (f) {
case OSystem::kFeatureFullscreenMode:
case OSystem::kFeatureIconifyWindow:
+ case OSystem::kFeatureVSync:
#if SDL_VERSION_ATLEAST(2, 0, 0)
case OSystem::kFeatureFullscreenToggleKeepsContext:
- case OSystem::kFeatureVSync:
#endif
return true;
@@ -217,12 +215,10 @@ void OpenGLSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
_wantsFullScreen = enable;
break;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
case OSystem::kFeatureVSync:
assert(getTransactionMode() != kTransactionNone);
_vsync = enable;
break;
-#endif
case OSystem::kFeatureIconifyWindow:
if (enable) {
@@ -251,10 +247,9 @@ bool OpenGLSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
return _wantsFullScreen;
}
#endif
-#if SDL_VERSION_ATLEAST(2, 0, 0)
+
case OSystem::kFeatureVSync:
return _vsync;
-#endif
default:
return OpenGLGraphicsManager::getFeatureState(f);
@@ -598,6 +593,8 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
notifyContextDestroy();
}
+ SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, _vsync ? 1 : 0);
+
_hwScreen = SDL_SetVideoMode(width, height, 32, flags);
if (!_hwScreen) {
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index a9b153c6da7..322138e2cb5 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -76,9 +76,7 @@ private:
uint _graphicsScale;
bool _gotResize;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
bool _vsync;
-#endif
bool _wantsFullScreen;
uint _ignoreResizeEvents;
More information about the Scummvm-git-logs
mailing list