Add FPS cap and disable VSync by default
This commit is contained in:
parent
731d5d8df4
commit
87f51ac044
6 changed files with 32 additions and 3 deletions
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ class GlobalConfig {
|
|||
|
||||
bool realTimeEraser = true;
|
||||
|
||||
unsigned mainCallbackRate = 144;
|
||||
|
||||
struct TabletOptions {
|
||||
bool pressureAffectsBrushWidth = true;
|
||||
uint8_t middleClickButton = 1;
|
||||
|
|
@ -92,6 +94,7 @@ class GlobalConfig {
|
|||
void save_palettes();
|
||||
void load_palettes();
|
||||
void load_licenses();
|
||||
void update_main_loop_call_rate();
|
||||
|
||||
bool checkForUpdates = true;
|
||||
bool useNativeFilePicker = true;
|
||||
|
|
@ -108,7 +111,7 @@ class GlobalConfig {
|
|||
bool flipZoomToolDirection = false;
|
||||
|
||||
bool disableGraphicsDriverWorkarounds = false;
|
||||
int vsyncValue = 1;
|
||||
int vsyncValue = 0;
|
||||
|
||||
SDL_DateFormat dateFormat = SDL_DATE_FORMAT_DDMMYYYY;
|
||||
SDL_TimeFormat timeFormat = SDL_TIME_FORMAT_12HR;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,6 @@ class MainProgram {
|
|||
} updateCheckerData;
|
||||
|
||||
float calculate_gui_scale();
|
||||
|
||||
private:
|
||||
std::unordered_set<World*> tabsToClose;
|
||||
void close_set_to_close_tabs();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "../GUIStuff/ElementHelpers/ColorPickerHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/CheckBoxHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/NumberSliderHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/RadioButtonHelpers.hpp"
|
||||
#include "../World.hpp"
|
||||
#include "Helpers/StringHelpers.hpp"
|
||||
#include "PhoneDrawingProgramScreen.hpp"
|
||||
|
|
@ -1147,6 +1148,20 @@ void FileSelectScreen::settings_view() {
|
|||
slider_scalar_field(gui, "tablet brush minimum size", "Brush relative minimum size", &main.conf.tabletOptions.brushMinimumSize, 0.0f, 1.0f, {.decimalPrecision = 3});
|
||||
slider_scalar_field(gui, "tablet brush pressure smoothing factor", "Brush pressure smoothing factor", &main.conf.tabletOptions.brushPressureSmoothingFactor, 0.0f, 1.0f, {.decimalPrecision = 3});
|
||||
checkbox_boolean_field(gui, "pen pressure width", "Pen pressure affects brush size", &main.conf.tabletOptions.pressureAffectsBrushWidth);
|
||||
text_label(gui, "VSync:");
|
||||
radio_button_selector(gui, "VSync selector", &main.conf.vsyncValue, {
|
||||
{"On", 1},
|
||||
{"Off", 0},
|
||||
{"Adaptive", -1}
|
||||
}, [&] {
|
||||
main.set_vsync_value(main.conf.vsyncValue);
|
||||
});
|
||||
input_scalar_field<unsigned>(gui, "FPS cap", "FPS Cap", &main.conf.mainCallbackRate, 10, 100000, {
|
||||
.onEdit = [&] {
|
||||
main.conf.update_main_loop_call_rate();
|
||||
}
|
||||
});
|
||||
checkbox_boolean_field(gui, "real time eraser", "Eraser works in real time", &main.conf.realTimeEraser);
|
||||
#ifndef __ANDROID__
|
||||
checkbox_boolean_field(gui, "use mobile UI", "Use mobile UI (requires restart)", &main.conf.mobileUI);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1546,6 +1546,11 @@ void Toolbar::general_settings_inner_gui() {
|
|||
}, [&] {
|
||||
main.set_vsync_value(main.conf.vsyncValue);
|
||||
});
|
||||
input_scalar_field<unsigned>(gui, "FPS cap", "FPS Cap", &main.conf.mainCallbackRate, 10, 100000, {
|
||||
.onEdit = [&] {
|
||||
main.conf.update_main_loop_call_rate();
|
||||
}
|
||||
});
|
||||
|
||||
checkbox_boolean_field(gui, "real time eraser", "Eraser works in real time", &main.conf.realTimeEraser);
|
||||
checkbox_boolean_field(gui, "force extension on path", "Force extension on path when saving files", &main.conf.forceExtensionOnPath);
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ void initialize_sdl(MainStruct& mS) {
|
|||
// Take maximize and fullscreen into account
|
||||
SDL_GetWindowSize(mS.window, &mS.m->window.size.x(), &mS.m->window.size.y());
|
||||
mS.m->input.update_safe_area();
|
||||
mS.m->conf.update_main_loop_call_rate();
|
||||
}
|
||||
|
||||
void sdl_terminate(MainStruct& mS) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue