mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2024-10-28 11:19:36 +01:00
Merge pull request #86 from Eblo/graphics-transition-fps-bugfix
Graphics.transition average FPS bugfix
This commit is contained in:
commit
4658487bb7
2 changed files with 31 additions and 8 deletions
|
@ -1085,14 +1085,7 @@ struct GraphicsPrivate {
|
|||
|
||||
swapGLBuffer();
|
||||
|
||||
SDL_LockMutex(avgFPSLock);
|
||||
if (avgFPSData.size() > 40)
|
||||
avgFPSData.erase(avgFPSData.begin());
|
||||
|
||||
double time = shState->runTime();
|
||||
avgFPSData.push_back(time - last_avg_update);
|
||||
last_avg_update = time;
|
||||
SDL_UnlockMutex(avgFPSLock);
|
||||
updateAvgFPS();
|
||||
}
|
||||
|
||||
void checkSyncLock() {
|
||||
|
@ -1132,6 +1125,17 @@ struct GraphicsPrivate {
|
|||
|
||||
SDL_UnlockMutex(glResourceLock);
|
||||
}
|
||||
|
||||
void updateAvgFPS() {
|
||||
SDL_LockMutex(avgFPSLock);
|
||||
if (avgFPSData.size() > 40)
|
||||
avgFPSData.erase(avgFPSData.begin());
|
||||
|
||||
double time = shState->runTime();
|
||||
avgFPSData.push_back(time - last_avg_update);
|
||||
last_avg_update = time;
|
||||
SDL_UnlockMutex(avgFPSLock);
|
||||
}
|
||||
};
|
||||
|
||||
Graphics::Graphics(RGSSThreadData *data) {
|
||||
|
@ -1311,6 +1315,8 @@ void Graphics::transition(int duration, const char *filename, int vague) {
|
|||
GLMeta::blitEnd();
|
||||
|
||||
p->swapGLBuffer();
|
||||
/* Call this manually, as redrawScreen() is not called during this loop. */
|
||||
p->updateAvgFPS();
|
||||
}
|
||||
|
||||
glState.blend.pop();
|
||||
|
|
17
tests/graphics-transition/transition.rb
Normal file
17
tests/graphics-transition/transition.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Test script for mkxp-z Graphics.transition reported FPS bug fix.
|
||||
# Run via the "customScript" field in mkxp.json.
|
||||
|
||||
puts 'No transition. Counter should be normal'
|
||||
normal_duration = 2
|
||||
Graphics.wait(normal_duration * Graphics.frame_rate)
|
||||
|
||||
transition_duration = 10 # Default value used in RGSS
|
||||
num_transitions = 20
|
||||
puts 'Performing transitions. If the FPS counter notably dips, the bug is not fixed.'
|
||||
num_transitions.times do
|
||||
Graphics.freeze
|
||||
Graphics.transition(transition_duration)
|
||||
Graphics.wait(transition_duration)
|
||||
end
|
||||
|
||||
exit
|
Loading…
Reference in a new issue