Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add target fps to render fps #9

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion draw-divide/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

This mod makes the game only render at your native refresh rate, even when you have an unlocked FPS, helping perfomance, specially for those with worse GPUs.

This works by only rendering the game at 60fps (or whatever your refresh rate is), while still running all the logic to whatever fps you set the game to.
This works by only rendering the game at 60fps (or whatever you set the render fps to), while still running all the logic to whatever fps you set the game to.

Meaning you get the benefit of fps bypass (lower input delay) while also not lagging as much due to rendering the game at such high fps.
31 changes: 3 additions & 28 deletions draw-divide/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@

using namespace geode::prelude;

double get_refresh_rate() {
static const double refresh_rate = [] {
DEVMODEA device_mode;
memset(&device_mode, 0, sizeof(device_mode));
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;

if (EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &device_mode) == 0) {
return 60.0;
} else {
// TODO: see if there is a way to get the exact frequency?
// like 59.940hz
auto freq = device_mode.dmDisplayFrequency;
// interlaced screens actually display twice of the reported frequency
if (device_mode.dmDisplayFlags & DM_INTERLACED) {
freq *= 2;
}
return static_cast<double>(freq);
}
}();
return refresh_rate;
}

double delta_count = 0.0;
bool enabled = true;

Expand All @@ -36,10 +13,8 @@ class $modify(CCDirector) {
return CCDirector::drawScene();
}

// always target the refresh rate of the monitor
const double target_fps = get_refresh_rate();

const double target_delta = 1.0 / target_fps;
// always target the fps set in settings
const double target_delta = 1.0 / Mod::get()->getSettingValue<int64_t>("fps");

delta_count += this->getActualDeltaTime();

Expand All @@ -63,4 +38,4 @@ class $modify(CCDirector) {
this->setNextScene();
}
}
};
};
17 changes: 15 additions & 2 deletions draw-divide/mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
{
"geode": "v2.0.0",
"gd": "*",
"version": "v1.0.1",
"version": "v1.0.2",
"id": "mat.draw-divide",
"name": "Draw divide",
"developer": "mat",
"description": "Makes the game render at native refresh rate, helping perfomance.",
"repository": "https://github.com/matcool/geode-mods"
"repository": "https://github.com/matcool/geode-mods",
"settings": {
"fps": {
"name": "Render FPS",
"type": "int",
"default": 60,
"min": 60,
"control": {
"input": true,
"slider": false,
"arrows": false
}
}
}
}