SaveTool: remove the FPS cap implementation.
I should port the code from my raycaster engine to here.
This commit is contained in:
parent
c5b4747685
commit
df5fa7a39e
4 changed files with 7 additions and 35 deletions
|
@ -136,10 +136,6 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
case Framelimit::HalfVsync:
|
case Framelimit::HalfVsync:
|
||||||
setSwapInterval(2);
|
setSwapInterval(2);
|
||||||
break;
|
break;
|
||||||
case Framelimit::FpsCap:
|
|
||||||
setSwapInterval(0);
|
|
||||||
setMinimalLoopPeriod(1000/_fpsCap);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
@ -184,9 +180,8 @@ SaveTool::~SaveTool() {
|
||||||
case Framelimit::HalfVsync:
|
case Framelimit::HalfVsync:
|
||||||
_conf.setValue("frame_limit"_s, "half_vsync"_s);
|
_conf.setValue("frame_limit"_s, "half_vsync"_s);
|
||||||
break;
|
break;
|
||||||
case Framelimit::FpsCap:
|
default:
|
||||||
_conf.setValue<UnsignedInt>("frame_limit"_s, _fpsCap);
|
_conf.setValue("frame_limit"_s, "vsync"_s);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_conf.save();
|
_conf.save();
|
||||||
|
|
|
@ -262,10 +262,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
|
|
||||||
enum class Framelimit: UnsignedByte {
|
enum class Framelimit: UnsignedByte {
|
||||||
Vsync,
|
Vsync,
|
||||||
HalfVsync,
|
HalfVsync
|
||||||
FpsCap
|
|
||||||
} _framelimit{Framelimit::Vsync};
|
} _framelimit{Framelimit::Vsync};
|
||||||
UnsignedInt _fpsCap{60};
|
|
||||||
|
|
||||||
bool _skipDisclaimer{false};
|
bool _skipDisclaimer{false};
|
||||||
bool _checkUpdatesOnStartup{true};
|
bool _checkUpdatesOnStartup{true};
|
||||||
|
|
|
@ -73,15 +73,11 @@ void SaveTool::initialiseConfiguration() {
|
||||||
|
|
||||||
if(_conf.hasValue("frame_limit"_s)) {
|
if(_conf.hasValue("frame_limit"_s)) {
|
||||||
std::string frame_limit = _conf.value("frame_limit"_s);
|
std::string frame_limit = _conf.value("frame_limit"_s);
|
||||||
if(frame_limit == "vsync"_s) {
|
if(frame_limit == "half_vsync"_s) {
|
||||||
_framelimit = Framelimit::Vsync;
|
|
||||||
}
|
|
||||||
else if(frame_limit == "half_vsync"_s) {
|
|
||||||
_framelimit = Framelimit::HalfVsync;
|
_framelimit = Framelimit::HalfVsync;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_framelimit = Framelimit::FpsCap;
|
_framelimit = Framelimit::Vsync;
|
||||||
_fpsCap = std::stoul(frame_limit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -58,11 +58,10 @@ void SaveTool::drawMainMenu() {
|
||||||
drawAlignedText("Frame limiter:");
|
drawAlignedText("Frame limiter:");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
static const char* framelimit_labels[3] = {
|
|
||||||
static auto selection = static_cast<UnsignedByte>(_framelimit);
|
static auto selection = static_cast<UnsignedByte>(_framelimit);
|
||||||
|
static const char* framelimit_labels[2] = {
|
||||||
"V-sync",
|
"V-sync",
|
||||||
"Half V-sync",
|
"Half V-sync"
|
||||||
"FPS cap, no V-sync"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
||||||
|
@ -77,26 +76,10 @@ void SaveTool::drawMainMenu() {
|
||||||
_framelimit = Framelimit::HalfVsync;
|
_framelimit = Framelimit::HalfVsync;
|
||||||
setSwapInterval(2);
|
setSwapInterval(2);
|
||||||
}
|
}
|
||||||
if(ImGui::Selectable(framelimit_labels[2], _framelimit == Framelimit::FpsCap)) {
|
|
||||||
selection = 2;
|
|
||||||
_framelimit = Framelimit::FpsCap;
|
|
||||||
setSwapInterval(0);
|
|
||||||
setMinimalLoopPeriod(1000 / _fpsCap);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_framelimit == Framelimit::FpsCap) {
|
|
||||||
static constexpr UnsignedInt min_fps = 15;
|
|
||||||
static constexpr UnsignedInt max_fps = 150;
|
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
|
||||||
if(ImGui::SliderScalar("##FpsSlider", ImGuiDataType_U32, &_fpsCap, &min_fps, &max_fps, "%u FPS", ImGuiSliderFlags_AlwaysClamp)) {
|
|
||||||
setMinimalLoopPeriod(1000 / _fpsCap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Checkbox("Cheat mode", &_cheatMode);
|
ImGui::Checkbox("Cheat mode", &_cheatMode);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
|
|
Loading…
Reference in a new issue