From a3f55de6eb8f70c33c13039bd0d7783435fe19c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Hlavat=C3=BD?= Date: Mon, 10 Apr 2023 14:53:05 +0200 Subject: [PATCH 1/2] FIX issue-1566 - framerate stuck to 1 --- libs/s25main/GameManager.cpp | 2 +- libs/s25main/Settings.cpp | 6 +++--- libs/s25main/Settings.h | 2 +- libs/s25main/desktops/Desktop.cpp | 6 +++--- libs/s25main/desktops/dskGameInterface.cpp | 2 +- libs/s25main/desktops/dskOptions.cpp | 24 +++++++++++----------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libs/s25main/GameManager.cpp b/libs/s25main/GameManager.cpp index 3da5daf27..1c8d7ef0c 100644 --- a/libs/s25main/GameManager.cpp +++ b/libs/s25main/GameManager.cpp @@ -52,7 +52,7 @@ bool GameManager::Start() settings_.video.fullscreen ? settings_.video.fullscreenSize : settings_.video.windowedSize; //-V807 if(!videoDriver_.CreateScreen(screenSize, settings_.video.fullscreen)) return false; - videoDriver_.setTargetFramerate(settings_.video.vsync); + videoDriver_.setTargetFramerate(settings_.video.framerate); videoDriver_.SetMouseWarping(settings_.global.smartCursor); /// Audiodriver laden diff --git a/libs/s25main/Settings.cpp b/libs/s25main/Settings.cpp index f3160ecaa..32142ec08 100644 --- a/libs/s25main/Settings.cpp +++ b/libs/s25main/Settings.cpp @@ -90,7 +90,7 @@ void Settings::LoadDefaults() video.windowedSize = video.fullscreenSize = VideoMode(800, 600); video.fullscreen = false; } - video.vsync = 0; + video.framerate = 0; // Special value for HW vsync video.vbo = true; video.shared_textures = true; // } @@ -224,7 +224,7 @@ void Settings::Load() video.fullscreenSize.width = iniVideo->getIntValue("fullscreen_width"); video.fullscreenSize.height = iniVideo->getIntValue("fullscreen_height"); video.fullscreen = iniVideo->getBoolValue("fullscreen"); - video.vsync = iniVideo->getBoolValue("vsync"); + video.framerate = iniVideo->getIntValue("framerate"); video.vbo = iniVideo->getBoolValue("vbo"); video.shared_textures = iniVideo->getBoolValue("shared_textures"); // }; @@ -402,7 +402,7 @@ void Settings::Save() iniVideo->setValue("windowed_width", video.windowedSize.width); iniVideo->setValue("windowed_height", video.windowedSize.height); iniVideo->setValue("fullscreen", video.fullscreen); - iniVideo->setValue("vsync", video.vsync); + iniVideo->setValue("framerate", video.framerate); iniVideo->setValue("vbo", video.vbo); iniVideo->setValue("shared_textures", video.shared_textures); // }; diff --git a/libs/s25main/Settings.h b/libs/s25main/Settings.h index 813daa94e..a435a3242 100644 --- a/libs/s25main/Settings.h +++ b/libs/s25main/Settings.h @@ -59,7 +59,7 @@ class Settings : public Singleton struct { VideoMode fullscreenSize, windowedSize; - signed short vsync; // <0 for unlimited, 0 for HW Vsync + signed short framerate; // <0 for unlimited, 0 for HW Vsync bool fullscreen; bool vbo; bool shared_textures; diff --git a/libs/s25main/desktops/Desktop.cpp b/libs/s25main/desktops/Desktop.cpp index 3b895469d..5a4db4253 100644 --- a/libs/s25main/desktops/Desktop.cpp +++ b/libs/s25main/desktops/Desktop.cpp @@ -26,11 +26,11 @@ Desktop::Desktop(glArchivItem_Bitmap* background) { SetScale(true); SetFpsDisplay(true); - // By default limit the maximum frame rate to 60 FPS - if(SETTINGS.video.vsync < 0) + // By default limit the maximum frame rate to 60 FPS - used for main menu + if(SETTINGS.video.framerate < 0) VIDEODRIVER.setTargetFramerate(60); else - VIDEODRIVER.setTargetFramerate(SETTINGS.video.vsync); + VIDEODRIVER.setTargetFramerate(SETTINGS.video.framerate); UpdateFps(VIDEODRIVER.GetFPS()); } diff --git a/libs/s25main/desktops/dskGameInterface.cpp b/libs/s25main/desktops/dskGameInterface.cpp index 340fe23b8..42bb9c12f 100644 --- a/libs/s25main/desktops/dskGameInterface.cpp +++ b/libs/s25main/desktops/dskGameInterface.cpp @@ -141,7 +141,7 @@ dskGameInterface::dskGameInterface(std::shared_ptr game, std::shared_ptrAddTextButton(ID_btOff, DrawPoint(280, 125), Extent(190, 22), TextureColor::Grey, _("Windowed"), NormalFont); - // "VSync" - groupGrafik->AddText(ID_txtVSync, DrawPoint(80, 180), _("Limit Framerate:"), COLOR_YELLOW, FontStyle{}, NormalFont); - groupGrafik->AddComboBox(ID_cbVSync, DrawPoint(280, 175), Extent(390, 22), TextureColor::Grey, NormalFont, 150); + groupGrafik->AddText(ID_txtFramerate, DrawPoint(80, 180), _("Limit Framerate:"), COLOR_YELLOW, FontStyle{}, + NormalFont); + groupGrafik->AddComboBox(ID_cbFramerate, DrawPoint(280, 175), Extent(390, 22), TextureColor::Grey, NormalFont, 150); // "VBO" groupGrafik->AddText(ID_txtVBO, DrawPoint(80, 230), _("Vertex Buffer Objects:"), COLOR_YELLOW, FontStyle{}, @@ -382,7 +382,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) groupGrafik->GetCtrl(ID_grpFullscreen)->SetSelection(SETTINGS.video.fullscreen); //-V807 // "Limit Framerate" füllen - auto* cbFrameRate = groupGrafik->GetCtrl(ID_cbVSync); + auto* cbFrameRate = groupGrafik->GetCtrl(ID_cbFramerate); if(VIDEODRIVER.HasVSync()) cbFrameRate->AddString(_("Dynamic (Limits to display refresh rate, works with most drivers)")); for(int framerate : Settings::SCREEN_REFRESH_RATES) @@ -391,7 +391,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0)) cbFrameRate->AddString(_("Disabled")); else cbFrameRate->AddString(helpers::toString(framerate) + " FPS"); - if(SETTINGS.video.vsync == framerate) + if(SETTINGS.video.framerate == framerate) cbFrameRate->SetSelection(cbFrameRate->GetNumItems() - 1); } if(!cbFrameRate->GetSelection()) @@ -478,17 +478,17 @@ void dskOptions::Msg_Group_ComboSelectItem(const unsigned group_id, const unsign ->SetEnabled(true); break; case ID_cbResolution: SETTINGS.video.fullscreenSize = video_modes[selection]; break; - case ID_cbVSync: + case ID_cbFramerate: if(VIDEODRIVER.HasVSync()) { if(selection == 0) - SETTINGS.video.vsync = 0; + SETTINGS.video.framerate = 0; else - SETTINGS.video.vsync = Settings::SCREEN_REFRESH_RATES[selection - 1]; + SETTINGS.video.framerate = Settings::SCREEN_REFRESH_RATES[selection - 1]; } else - SETTINGS.video.vsync = Settings::SCREEN_REFRESH_RATES[selection]; + SETTINGS.video.framerate = Settings::SCREEN_REFRESH_RATES[selection]; - VIDEODRIVER.setTargetFramerate(SETTINGS.video.vsync); + VIDEODRIVER.setTargetFramerate(SETTINGS.video.framerate); break; case ID_cbVideoDriver: SETTINGS.driver.video = combo->GetText(selection); break; case ID_cbAudioDriver: SETTINGS.driver.audio = combo->GetText(selection); break; From 92ee6a769090f5dfe9cc6d69e0446299312df821 Mon Sep 17 00:00:00 2001 From: Xellzul Date: Mon, 10 Apr 2023 17:44:41 +0200 Subject: [PATCH 2/2] Update libs/s25main/Settings.cpp Co-authored-by: Alexander Grund --- libs/s25main/Settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/s25main/Settings.cpp b/libs/s25main/Settings.cpp index 32142ec08..068ce1d49 100644 --- a/libs/s25main/Settings.cpp +++ b/libs/s25main/Settings.cpp @@ -224,7 +224,7 @@ void Settings::Load() video.fullscreenSize.width = iniVideo->getIntValue("fullscreen_width"); video.fullscreenSize.height = iniVideo->getIntValue("fullscreen_height"); video.fullscreen = iniVideo->getBoolValue("fullscreen"); - video.framerate = iniVideo->getIntValue("framerate"); + video.framerate = iniVideo->getValue("framerate", 0); video.vbo = iniVideo->getBoolValue("vbo"); video.shared_textures = iniVideo->getBoolValue("shared_textures"); // };