Add FPS cap and disable VSync by default

This commit is contained in:
Yousef Khadadeh 2026-06-02 18:47:39 +03:00
parent 731d5d8df4
commit 87f51ac044
6 changed files with 32 additions and 3 deletions

View file

@ -48,6 +48,7 @@ nlohmann::json GlobalConfig::get_config_json(const InputManager& input) const {
toRet["keybinds"] = jKeybinds;
toRet["guiScale"] = guiScale;
toRet["jumpTransitionTime"] = jumpTransitionTime;
toRet["mainCallbackRate"] = mainCallbackRate;
toRet["disableGraphicsDriverWorkarounds"] = disableGraphicsDriverWorkarounds;
toRet["viewWebVersionWelcome"] = viewWebVersionWelcome;
toRet["dragZoomSpeed"] = dragZoomSpeed;
@ -120,7 +121,9 @@ void GlobalConfig::set_config_json(InputManager& input, const nlohmann::json& j,
try{j.at("displayName").get_to(displayName);} catch(...) {}
try{j.at("dragZoomSpeed").get_to(dragZoomSpeed);} catch(...) {}
try{j.at("scrollZoomSpeed").get_to(scrollZoomSpeed);} catch(...) {}
try{j.at("vsync").get_to(vsyncValue);} catch(...) {}
try{j.at("mainCallbackRate").get_to(mainCallbackRate);} catch(...) {}
if(version >= VersionNumber(0, 6, 0))
try{j.at("vsync").get_to(vsyncValue);} catch(...) {}
#ifndef __EMSCRIPTEN__
try{j.at("applyDisplayScale").get_to(applyDisplayScale);} catch(...) {}
#endif
@ -211,3 +214,6 @@ void GlobalConfig::load_licenses() {
ownLicenseText += read_file_to_string("data/license");
}
void GlobalConfig::update_main_loop_call_rate() {
SDL_SetHint(SDL_HINT_MAIN_CALLBACK_RATE, std::to_string(mainCallbackRate).c_str());
}