Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions Core/GameEngine/Include/Common/FramePacer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FramePacer
~FramePacer();

void update(); ///< Signal that the app/render update is done and wait for the fps limit if applicable.
void reset(); ///< Move the frame timing anchor to now and predict the next update time from the target frame rate. Call after a long blocking operation so its duration does not leak into the next frame delta.

void setFramesPerSecondLimit( Int fps ); ///< Set the update fps limit.
Int getFramesPerSecondLimit() const; ///< Get the update fps limit.
Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Include/Common/FrameRateLimit.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class FrameRateLimit
FrameRateLimit();

Real wait(UnsignedInt maxFps);
void reset(); ///< Move the timing anchor to now, discarding any time elapsed since the last call to wait.

private:
Int64 m_freq;
Expand Down
6 changes: 6 additions & 0 deletions Core/GameEngine/Source/Common/FramePacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ void FramePacer::update()
m_updateTime = m_frameRateLimit.wait(maxFps);
}

void FramePacer::reset()
{
m_frameRateLimit.reset();
m_updateTime = 1.0f / (Real)getActualFramesPerSecondLimit();
}

void FramePacer::setFramesPerSecondLimit( Int fps )
{
DEBUG_LOG(("FramePacer::setFramesPerSecondLimit() - setting max fps to %d (TheGlobalData->m_useFpsLimit == %d)", fps, TheGlobalData->m_useFpsLimit));
Expand Down
7 changes: 7 additions & 0 deletions Core/GameEngine/Source/Common/FrameRateLimit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Real FrameRateLimit::wait(UnsignedInt maxFps)
return (Real)elapsedSeconds;
}

void FrameRateLimit::reset()
{
LARGE_INTEGER tick;
QueryPerformanceCounter(&tick);
m_start = tick.QuadPart;
}


const UnsignedInt RenderFpsPreset::s_fpsValues[] = {
30, 50, 56, 60, 65, 70, 72, 75, 80, 85, 90, 100, 110, 120, 144, 240, 480, UncappedFpsValue };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,7 @@ void GameLogic::tryStartNewGame( Bool loadingSaveGame )
// if we're in a load game, don't fade yet
if(loadingSaveGame == FALSE && TheTransitionHandler != nullptr && m_loadScreen)
{
TheFramePacer->reset();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Calling TheFramePacer->update(); twice here would probably also work, but cause a mini wait then. reset() does not cause wait.

TheTransitionHandler->setGroup("FadeWholeScreen");
while(!TheTransitionHandler->isFinished())
{
Expand Down
Loading