Skip to content

[WIP] add variable FPS & VSync#3047

Draft
mercury233 wants to merge 14 commits into
Fluorohydride:masterfrom
mercury233:patch-vsync-v2
Draft

[WIP] add variable FPS & VSync#3047
mercury233 wants to merge 14 commits into
Fluorohydride:masterfrom
mercury233:patch-vsync-v2

Conversation

@mercury233

Copy link
Copy Markdown
Collaborator
  • Change the previously fixed frame rate of 60 to a configurable value, and adjust the number of animation frames based on the frame rate multiplier.
  • Add the vertical sync option; in this mode, the system automatically sets the frame rate to match the display’s refresh rate.
  • Add a frame rate configuration: when vertical sync is disabled, it sets the target frame rate; when vertical sync is enabled, it is used as a fallback for manual configuration if the display’s refresh rate cannot be obtained.

Known issues:

  • On Linux, enabling vertical sync may cause errors on some GPUs, while on others it has no effect.
  • Retrieving the display refresh rate is not implemented on Linux.
  • On macOS, enabling vertical sync may result in double the frame rate.
  • Some animations still require fine-tuning.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable FPS and VSync support to the gframe rendering/game loop, and updates multiple UI/animation paths to keep animation timing consistent when running above 60 FPS.

Changes:

  • Introduces vsync and target_fps config options, derives an effectiveFps, and scales timing/animation steps using fpsScale plus a 60Hz-ish logicalTick.
  • Updates card movement/fade and several UI animations to be frame-rate aware (new ScaleFrame(), SetCardMovement(), float alpha handling).
  • Adjusts LP animation and various per-frame increments to remain time-consistent across frame rates.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
gframe/game.h Adds new config fields and frame-scaling state used by the main loop and animations.
gframe/game.cpp Applies VSync at device creation; computes effectiveFps/fpsScale; updates the main loop timing and adds ScaleFrame().
gframe/duelclient.cpp Switches many ad-hoc movement setups to SetCardMovement() and updates LP animation setup for scaled frames.
gframe/drawing.cpp Converts multiple animations to scale by FPS and uses logicalTick; updates fade/LP logic to be frame-rate aware.
gframe/client_field.h Adds SetCardMovement() and renames parameters to frame60 to clarify semantics.
gframe/client_field.cpp Implements SetCardMovement() and scales MoveCard()/FadeCard() durations via ScaleFrame().
gframe/client_card.h Changes alpha fields to float and adds targetAlpha to stabilize fade completion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gframe/game.cpp
Comment on lines +93 to +110
effectiveFps = gameConf.target_fps;
if(gameConf.vsync && effectiveFps <= 0) {
int detectedFps = 0;
#ifdef _WIN32
DEVMODE dm{};
dm.dmSize = sizeof(dm);
if(EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) && dm.dmDisplayFrequency > 0)
detectedFps = (int)dm.dmDisplayFrequency;
#elif defined(__APPLE__)
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(CGMainDisplayID());
if(mode) {
double rate = CGDisplayModeGetRefreshRate(mode);
if(rate > 0) detectedFps = (int)rate;
CGDisplayModeRelease(mode);
}
#endif
if(detectedFps > 0) effectiveFps = detectedFps;
}
Comment thread gframe/game.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants