[WIP] add variable FPS & VSync#3047
Draft
mercury233 wants to merge 14 commits into
Draft
Conversation
was reducing signalFrame but not progressing anim in DrawCards etc.
Contributor
There was a problem hiding this comment.
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
vsyncandtarget_fpsconfig options, derives aneffectiveFps, and scales timing/animation steps usingfpsScaleplus a 60Hz-ishlogicalTick. - 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 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; | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Known issues: