mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 10:49:53 +02:00
Fix incorrect FPS counter, need to count blit too.
2x scale gets a massive *real* fps boost, the fps lied before.
This commit is contained in:
@@ -495,29 +495,6 @@ void EngineProcess()
|
|||||||
frameStart = SDL_GetTicks();
|
frameStart = SDL_GetTicks();
|
||||||
engine->Tick();
|
engine->Tick();
|
||||||
engine->Draw();
|
engine->Draw();
|
||||||
frameTime = SDL_GetTicks() - frameStart;
|
|
||||||
|
|
||||||
frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime);
|
|
||||||
if(ui::Engine::Ref().FpsLimit > 2.0f)
|
|
||||||
{
|
|
||||||
float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit);
|
|
||||||
if(targetFrameTime - frameTimeAvg > 0)
|
|
||||||
{
|
|
||||||
SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f);
|
|
||||||
frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime);
|
|
||||||
fps = 1000.0f/correctedFrameTimeAvg;
|
|
||||||
engine->SetFps(fps);
|
|
||||||
|
|
||||||
if(frameStart-lastTick>250)
|
|
||||||
{
|
|
||||||
//Run client tick every second
|
|
||||||
lastTick = frameStart;
|
|
||||||
Client::Ref().Tick();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(scale != engine->Scale || fullscreen != engine->Fullscreen)
|
if(scale != engine->Scale || fullscreen != engine->Fullscreen)
|
||||||
{
|
{
|
||||||
@@ -533,6 +510,28 @@ void EngineProcess()
|
|||||||
else
|
else
|
||||||
blit(engine->g->vid);
|
blit(engine->g->vid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
frameTime = SDL_GetTicks() - frameStart;
|
||||||
|
frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime);
|
||||||
|
if(ui::Engine::Ref().FpsLimit > 2.0f)
|
||||||
|
{
|
||||||
|
float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit);
|
||||||
|
if(targetFrameTime - frameTimeAvg > 0)
|
||||||
|
{
|
||||||
|
SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f);
|
||||||
|
frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime);
|
||||||
|
fps = 1000.0f/correctedFrameTimeAvg;
|
||||||
|
engine->SetFps(fps);
|
||||||
|
|
||||||
|
if(frameStart-lastTick>250)
|
||||||
|
{
|
||||||
|
//Run client tick every second
|
||||||
|
lastTick = frameStart;
|
||||||
|
Client::Ref().Tick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "Breaking out of EngineProcess" << std::endl;
|
std::cout << "Breaking out of EngineProcess" << std::endl;
|
||||||
|
Reference in New Issue
Block a user